Hello,
I will create frienship system for my project. I couldn't decide whether I should store friends in a column at user's row or create a friends table and store there with user IDs? To clearify which usage is better:
Should users table be like this?
+-----------+-----------+---------------+
+ id + username + friends +
+-----------+-----------+---------------+
+ 11 + user_x + 12;23;15;3;7 +
+-----------+-----------+---------------+
with
<?php explode(';',$friends); ?>
or; Sould I create a friends table like this?
+-----------+-----------+---------------+
+ id + user + friend +
+-----------+-----------+---------------+
+ 1 + 11 + 12 +
+-----------+-----------+---------------+
+ 2 + 11 + 23 +
+-----------+-----------+---------------+
+ 3 + 11 + 15 +
+-----------+-----------+---------------+
+ 4 + 11 + 3 +
+-----------+-----------+---------------+
+ 5 + 11 + 7 +
+-----------+-----------+---------------+
with
SELECT friend FROM friends WHERE user = 11
Which one is better? Thank you