Do you want to receive comments on products, users, reviews, etc.? Or find the products, users, reviews, etc. that the comment refers to?
For the first, I would have tables to associate things with their comments:
create table join_products_comments ( product_id int (unique, ie, one thread of comments per product), comment_thread_id int ); create table join_users_comments ( user_id int (unique, ie, one thread of comments per user), comment_thread_id int );
Where comment_thread is just a link to a thread that refers to each comment:
create table comment_threads ( thread_id int (PK), thread_name nvarchar2(256), created datetime ); create table comments ( comment_id int (PK), comment_thread_id int (FK), parent_comment_id int (FK), user_id int (FK),
Thus, each remarkable object in the system will have a connection table and one comment_thread, waiting for users to add comments. Or you could just refer to the root comment instead and without this indirection.
source share