I've been working on one too recently and pretty much had the exact same structure. I didn't have deleted_at on the pivot though. Do you think that is that really needed?
Apr 13, 2016
4
Level 7
Best database structure to create a messaging system?
So I'm trying to create a messaging system (have been trying for 2 days non stop) and haven't found THE best database structure to use. I am thinking of creating a "threaded" system; like Gmail's -- it's got inbox, sent, deleted, etc.
I have thought of this schema, please let me know if you have a better one.
threads: id, subject, user_id
messages: id, user_id, body
message_user (pivot): id, user_id, message_id, deleted_at, read_at
How does this sound?
Please or to participate in this conversation.