Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Is this simple concept for a forum basically good?

forum sql conception generalization

This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1 abderrahim

abderrahim

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 58 posts

Posted 11 July 2013 - 07:10 AM

Hi every body!

I hope if someone here mention some faults/optimization in my primitive conception for a simple forum, knowing that I not keen on there things, 

here is a capture of the whole simple SQL database,

I'm so sorry for the order of different fields,  rearranging them seems somehow hard.

Thank's a lot!

Attached Thumbnails

  • Screenshot from 2013-07-11 16:02:22.png

Edited by abderrahim, 11 July 2013 - 07:12 AM.


#2 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts

Posted 11 July 2013 - 08:31 AM

looks good ... I would strongly suggest use  "singular for column name"   ... "likes" = like   instead or like_count and dislike_count ... basically you want to get the count ... for boolean   verified  use is_verified

 

forum.answer  id links to forum.content id ... that's confusing ...

 

why not have another forum-id ... just like id-person that you have to show a linking that would be the same for forum.questions ... it's pretty bad design to have id links to id


www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#3 abderrahim

abderrahim

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 58 posts

Posted 11 July 2013 - 09:04 AM

OK, thank you VNFox, I'll try to take in mind all what you said,

about the relation between content and answer, an "answer" or a "question" is a "content", isn't it a good way to generalize? or there is no need for it at all?



#4 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts

Posted 11 July 2013 - 09:07 AM

Whoa.  A couple of things.

 

ID should be your first field and your primary key for each table.  Foreign keys should have the table name and ID of the foreign table.  example: SubscriberID.

 

Name your tables for what they contain.  Your person table has nothing to do with a person.  In fact, I think those fields can be combined in the subscriber table, which is normally called a USER table.

 

Your answers should have a foreign key reference to your question table, or you won't know which belongs to what question.


My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#5 abderrahim

abderrahim

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 58 posts

Posted 11 July 2013 - 09:33 AM

Thank you lespauled,

about the order of ids, I think I can rearrenge them by

ALTER TABLE AanyTable CHANGE COLUMN anyColumn anyColumnDefinition before anotherColumn 

about person, perhapse I need to rename it to: visitor, but I need this table as it's different from subscriber or User table,

and finally about the relation between answer and question table you are totally alright.

Thank's



I'll try to upload my second version as soon as I can.



#6 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts

Posted 11 July 2013 - 09:44 AM

I just notice that all your table names begin with forum.something ... I don't think you need to have forum.[just use the name].  In addition, never have table name in plural  ... always use singular.  When I think about the forum it's the topic and post.   I guess question and answer seem to be okay.  I dont' know about the content table.  What's the content table is for anyway?  Can you just have person_id in the question and answer table ? Basically you just want to know who posts it right ?

 

Sorry my mistake ... I just realized forum. is the namespace.


Edited by VNFox, 11 July 2013 - 09:47 AM.

www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#7 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts

Posted 11 July 2013 - 11:34 AM

...  In addition, never have table name in plural  ... always use singular.  

 

Why? There is no difference.  In fact, a table like Questions, or Answers is perfectly fine.


My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#8 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 11 July 2013 - 11:58 AM

Just a thought: unless you record every like/dislike into a table with links to the user and message, you have no way to stop people from liking a post multiple times. Think about abuses of any feature you want to include, and make sure you have a way to store the necessary data to prevent it.


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#9 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts

Posted 11 July 2013 - 12:21 PM

Why? There is no difference.  In fact, a table like Questions, or Answers is perfectly fine.

 

One of the reason is to be consistence ... if you want to use plurals then make all table names plural.

 

Anyway ... you can learn more about by reading this article:

 

http://www.codeproje...tabase-Table-Na


www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#10 abderrahim

abderrahim

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 58 posts

Posted 11 July 2013 - 02:54 PM

Thank you all, thank's VNFox for the suitable article



#11 Barnsite

Barnsite

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 258 posts

Posted 12 July 2013 - 05:03 AM

Why? There is no difference.  In fact, a table like Questions, or Answers is perfectly fine.

 

 

One of the reason is to be consistence ... if you want to use plurals then make all table names plural.

 

Anyway ... you can learn more about by reading this article:

 

http://www.codeproje...tabase-Table-Na

 

Just to throw in my two pennyworth, I was always taught (although it was in the dim and distant past) that all table names should be singular. Plural names are somewhat redundant, unless you're going to have tables with only one row, we know that the Question table contains multiple Questions.  

 

Although I agree that it doesn't make a difference to functionality, it is like any convention in that it makes development easier as it adds consistency, you don't have to keep checking if you used singular or plural for particular tables.

 

You could of course decide to pluralise all your table names to be consistent, although you would end up with "statuses" tables and the like.


There are two ways to write error-free programs; only the third one works.

#12 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts

Posted 21 July 2013 - 08:20 AM

To elaborate WP's suggestion, you would need to track who likes or dislike what, to avoid abusing of like/dislike feature.

 

On the table names, I always use plural for table names. It would make the scripts closer to natural english sentence. At least to my taste. But do I hate words with the same plural and singular form! Lol. Recently I need a table to hold species information... darn :)


Edited by Luthfi, 21 July 2013 - 08:20 AM.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download