I'm wondering about the table structure for a threaded messaging system.
I'm thinking there will be 3 tables:
- message_thread
- id
- subject
- message_user
- thread_id
- user_id
- thread_status (unread, read, trash, deleted)
- message
- date (date sent)
- sent_user_id
- message
Each message_thread
would have 1 record in message_thread. Each user would have a record in message_user
relating them to that thread and also their read/deleted status for that thread. (message_user
might also contain some datetime fields as to when the different statuses occured.) The message table would contain the messages, the user that sent them and the time.
The system in the end would work similar to Facebook or looks like Gmail's (although not based on email).
Required:
- more than 2 users involved in the thread
- each user must have their own read/delete status for the thread
Is this the way you'd set it up?