I have the following tables: - posts - files - events - documents
Every post, file, event, document can have comments.
What is the better database scheme for this, and why?
First solution
- comments table (comment_id, author_id, comment)
- 4 tables to create relations (posts_comments(post_id, comment_id), files_comments(file_id, comment_id), events_comments(event_id, comment_id), documents_comments(document_id, comment_id))
Second solution
- comments table (comment_id, author_id, comment)
- items_comments (comment_id, parent_type (enum['post', 'file', 'event', 'document']), parent_id)
What is a better solution for this, or which one of two should I use?