I have the following tables: - messages - files - Events - documents
Each message, file, event, document may have comments.
What is the best database schema for this, and why ?
First decision
- comment table (comment_id, author_id, comment)
- 4 tables for creating relationships (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
- comment table (comment_id, author_id, comment)
- items_comments (comment_id, parent_type (enum ['post', 'file', 'event', 'document']), parent_id)
What is the best solution for this or which of the two should I use?