On my site, there is an area where users can write and send a message to any number of other users. That message is viewable to only the users specified by the message author. So I made 2 tables: Message_Author
and message_Receivers
and give them a common column of messageID
. For every message posted, one entry is inserted into Message_ Author
$db->query("
INSERT INTO Message_Author
VALUES('$message_id',$_SESSION[email],$message)
");
and into Message_Receivers:
foreach($receiversUserNameArray as &$value){
$db->query("
INSERT INTO Message_Receivers
VALUES('$message_id',$value)
");
}
So now every user specified by the message author can view the message with that message id. The problem is if a user wants to "send to all" contacts. This could potentially be hundreds usernames each with its own row taking up a lot of database space. So is there a better way of linking the messageID between these two tables without making a row for each receiver?