I am wondering how best to layout my database for my friends system? I was going to do it like this,
id (int) | friendID (int) | accepted (enum)
Which is how I think it should be done, just one question:
-
Upon a user confirming a request should I change the current row enum to yes and then insert another row for the user that confirmed it? ie;
1 | 4 | yes 4 | 1 | yes
Or is there a way I can pull both relationships from the one row without inserting another?
ie;
1 | 4 | yes
In this case I think it is better to insert twice for each friend, since space is cheap, and you’ll probably be adding friends less often than reading them. If you want to save space however, you can change the way you select the friends from:
to
then on the php side, you would check if friendId or id is the currently logged in user etc.