1

First DBA question. Greetings people.

I hope I'm not duplicating a question but it's very hard finding database design related questions here (for multiple comment tables), as all 'design' questions share similar or identical titles, like 'Best way to design this?' or 'How do I correctly design this database?' - they're not very descriptive!

Anyway, I have car magazine website that I'm trying to add a commenting system to. The site has a few areas that need comments, which aren't related to each other at all. For example, there's articles, videos, photos and technical guides that will all have commenting functionality.

Obviously, I'd like to build this database the most efficient way possible from the start, as we now have quite a few users that will quickly fill up the rows. The question I have is, do I build a comment table for each section, like this?

articleComments
---------------------
commentID
userID
articleID
comment
timePosted

techguideComments
---------------------
commentID
userID
techguideID
comment
timePosted

photoComments
---------------------
commentID
userID
photoID
comment
timePosted

videoComments
---------------------
commentID
userID
videoID
comment
timePosted

Or would it be better to build one table, but structure it like so:

comments
-----------------------------
commentID
userID
...
articleID
techguideID
photoID
videoID
...
comment
timePosted

My initial thought is to build a table for each section, but seeming as I'm not having replies - single threaded comments only - maybe one chunky would do and maybe one table is easier to manage. I'm really not sure.

What are the pros and cons for each design?

  • I would use only one ID and a ENUM-Field or a seperat table with comment_type (article, techguied, photo, video...) – da_didi Aug 10 '14 at 18:23
  • Maybe this answer will fit your needs : stackoverflow.com/questions/4088963/… – Masacc Dec 20 '16 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.