0

I have a table called Comment which stores comments of users. This Comment table should reference different types of content: revisions, posts, and other comments (using tables Revision, Post, and Comment respectively).

How should I design the database so that this can be achieved?

Edit: Just for clarity.

I have several types of content: Revision, Post, Comment. It is possible that other types may be addded in the future. For each type of content a user is able to comment. How do I construct my tables and references so that a Comment can be linked to the different types of content.

  • Perhaps it would be helpful if you describe your objective in more detail. The question is: Why to use generalization for Comments and not for Posts, Revisions etc. – Vojtěch Dohnal Aug 01 '17 at 08:59
  • Which part is lacking? I will update it as needed. I thought my description is concise. – Juan Dela Cruz Aug 01 '17 at 09:57
  • So you allow comments on comments? I meant that we do not see attributes of the types/classes and do not know what makes them distinct one from another. – Vojtěch Dohnal Aug 01 '17 at 10:10
  • If you are re-inventing the WP wheel, see this for "meta": http://mysql.rjweb.org/doc.php/index_cookbook_mysql#speeding_up_wp_postmeta – Rick James Aug 13 '17 at 23:09

0 Answers0