views:

156

answers:

1

Hello,

I am trying to design an mail system. I have stuttered on the problem that I have no solution yet, but maybe you can point me to some? My problem is I don't really imagine how does the database schema should look like if we are having two different tables for Inbox and Outbox. In example we also must have Users and Messages tables. So from my point of view I think that Message should have two Foreign key to both users ID's(primary key in Users table) from which we can identify sender and receiver. Afterwards it seems ok, but if we will start thinking that we must identify which of the both users should have this message in Inbox or Outbox? Only thing comes to mind if we will have Message fields like id, sender_id and receiver_id, text and etc. I don't think its a good maintainable design.. In example if we would like to have Message table not only for users conversations but on forum or somewhere else? Please correct me if I am wrong. Any help, suggestions, advices are welcome!

+1  A: 

Look at Zimbra for some inspiration. It's open source, and uses MySql to store the message metadata, while the actual messages are stored in the file system.

Jesse Weigert