Here is my current comment system design:
I'm developing it for a website that has lots of areas, blogs, tutorials, manuals etc etc. As supposed to developing a separate comment table for each (tblBlogComments
, tblTutorialComments
) etc etc, I'm trying to go for a one structure fits all approach.
This way, I can turn the comment system into a web control, and just drop it on any page that I want comments for. It means I only have one set of rules, one set of code files to maintain.
The only problem is, is coming up with a 'nice' way to determine which section (blog/tutorial/manual) belongs to.
For example, one solution would be:
tblComment
-------------
Section (int)
SectionIdentifier (int)
Where 'Section
' maps to a unique to each part of the site, EG:
Blog = 1
Articles = 2
Tutorials = 3
...
A SectionIdentifier
is some sort of unique ID for that page, eg:
ViewBlog.aspx?ID=5
This would be section 1, identifier 5. So now, a comment with Section = 1
, SectionIdentifier = 5
means it's a comment for blog entry number 5.
This works great, but at the cost of maintainability, and a solid structure, as the SectionIdentifier
is anonymous and no relationships can be built.
Is this design OK, or is there a better solution (IE some sort of parent table for a comment?)