Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to create messaging system like in facebook - any ideas for database design [closed]

I'm building a small messaging system like you have in facebook. Only thing is that I want to know whats the best way to get on about it. The database design to be precise in this case.

Like all users would have an inbox and sent items folder. Logically something in one persons sent folder would actually be in someone elses inbox. However I don't think using one table to hold the messages would work as lets say someone deletes a message form his sent box it would be gone since both reciever and sender would be referring to the same table. How do I implement this...

like image 540
Ali Avatar asked Aug 10 '09 06:08

Ali


1 Answers

Sometimes a schema is better than a long explanation :

users-message-db-design

With this design, if someone deletes a message, it only deletes a row in the "users_has_messages" table, and not the message itself.

Of course, I just threw in some fields for the example, you will need much more for your project.

like image 198
afewcc Avatar answered Oct 11 '22 17:10

afewcc