My site (ASP.NET/C#/MS-SQL 2005) has multiple sections that allow for comments (User profiles, image pages, videos, etc). I want to store everything in a single comments table.
My issue is linking the comment back to its parent. The user profiles’ primary keys are uniqueidentifiers, while the images and videos use ints. I’d like to have a foreign key relationship from the comment to its parent.
What would be considered best-practice for this?
I would use join tables, one for each section that allows comments. Then you would use whatever key you want for the comments table and your join table would just need to have the identifier from your section table and from your comments table.