I’m designing a messaging system that will have to support a huge amount of messages and users.
I was thinking about two solutions.
Usertable -> id, username ....
Messagetable -> id, from_id, to_id, message ...
Or:
Usertable -> id, username ....
Messagetable -> id, message ...
HasMessagetable -> id, from_id, to_id...
I’m wondering what is the best approach to this and why.
Also, are there good publications (free or not) about large databases design and best practices?
Thank you
I did the same not too long ago and started out with approach 1. But then users were supposed to be able to send messages to multiple users. Suddenly approach 1 saved each message n times if n recipients were addressed. So if this is ever a possibility, I think 2 is better.