Background: I am creating an application that allows users to comment on different object types. For simplicity sake, say I have Object A and Object B, both of which can be commented on. I want to store those comments in a database table. The data structure for comments for both objects is exactly the same, and the most common db query will be "get all comments for a specific Object A".
Question: Which of the following schemas would be most effective:
- A single table, Comments, with a column for "Type"
- Multiple tables, Comments_ObjectA and Comments_ObjectB, for each object type
- Something else I haven't considered
Example Usage
- Single table: "SELECT * FROM comment WHERE type="ObjectA" and id_object=123
- Multiple tables: "SELECT * FROM comment_objecta WHERE id_objecta=123"
Thank you for your help!