October 22, 2024
Chicago 12, Melborne City, USA
SQL

What is the best way to handles comments related to multiple tables in SQL?


I have a SQL structure that could be illustrated like so (simplified):
Parts, Variants, Machines, Persons. Each have different relations, e.g.;

  • 1 Part to many Variants
  • Many Parts to Many Machines
  • Many Persons to Many Parts

I need to be able to add comments to each entry in either one of these tables. So one Part/Variant/Machine/Person can have many comments. A comment entry always contains user_id, timestamp, comment_text

Should I just do a tables for each, e.g Part_Comments, Variant_Comments etc. Or could/should I make one table for all comments and include the table id somehow. So the columns would be something like: entry_id, table_id, user_id, timestamp, comment_text.

Is there a best practice for this?
Thanks



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video