I'm building a website that has several areas where comments are allowed (general topics, activities, groups, etc.).
I know I can create separate tables for each comment type. But I'm thinking it would be nice to be able to create one comment table that is used for all comment types. That would mean that, for any row in the comment table, it would be linked to one of several
Some possible ways of approaching this include:
1. Include multiple foreign-key columns in my comments table. Only one would be used and the rest would be NULL. (All would be indexed.)
2. Have a single column that contains a foreign-key value and another column that indicates the comment type. In this case, there would be no relationship constraints established in the database. It would simply be enforced by my code. To get comments related
to, for example, a specific activity, I would use something like WHERE ComParentID = @ActivityID AND ComType = TypeActivity.
I'm not sure if this approach makes much sense. Perhaps someone could comment which of these approaches sound better, or suggest a different approach altogether.
Thanks.Jonathan Wood • SoftCircuits •
View Complete Post