In my messaging application, The features I want to provide are:
- Sending a message to multiple people
- Receiving message sent to a user
- Showing message in groups divided by the users, Like in facebook message
- But when a user will send a message to multiple people, It will not be a group message but those messages will go in groups divided by users
My database schema is like this
This schema is able to provide all the functions above but getting the message out from this kind of schema in groups of users is very complex. Can anyone suggest me some better schema??
The unnamed table is of开发者_开发百科 receivers mapping, forgot to write the name in jpg. :(
What is wrong with one table?
message_id timestamp to from subject body attachment_pointer origin
...
I'll probably get thrashed for it but... hmm...good point
Messages
message_id
timestamp
subject
body
attachment
MessageReference
mr_id
message_id
to
from
edit: Also found these:
Messaging system database schema
thread messaging system database schema design
How should I setup my database schema for a messaging system complete with attachments?
Database schema for messaging to multiple users
Hi you can use a joining table. This is very simple architecture which lot of giants are using like YouTube, Reddit etc.
Here is a video explaining how only 2 queries will be bringing your app to live.
精彩评论