Generic Database table design
Posted
by Gazeth
on Stack Overflow
See other posts from Stack Overflow
or by Gazeth
Published on 2010-06-16T16:21:56Z
Indexed on
2010/06/16
16:32 UTC
Read the original article
Hit count: 176
Just trying to figure out the best way to design my table for the following scenario:
I have several areas in my system (documents, projects, groups and clients) and each of these can have comments logged against them.
My question is should I have one table like this:
CommentID
DocumentID
ProjectID
GroupID
ClientID
etc
Where only one of the ids will have data and the rest will be NULL or should I have a seperate CommentType table and have my comments table like this:
CommentID
CommentTypeID
ResourceID (this being the id of the project/doc/client)
etc
My thoughts are that option 2 would be more efficient from an indexing point of view?
© Stack Overflow or respective owner