Conversations
--------------
id
Messages
--------------
id
conversation_id
user_id
reply_to_id
content
created_at
I was looking at this question and I had a question: How to build a table for a private messaging system that supports replies?
Let's say you have a chat and two users messaging each other back and forth, and then another person joins, so an event says Third User has joined the chat.
How would you represent the event in a schema? It's technically just another message without a user_id, but allowing user_id to be null seems to violate data integrity. Is it better to just create a separate table? How would you design that table to allow easy joining so that each even is in the proper time?