I am working on Facebook application with nearly 1 mio users. For each user I need to insert into table a friends list. The friends list is used only in 1 page where items of user friends are shown.
When user register I have two options:
a)
"INSERT INTO friends (userId, friendId) VALUES ".$friendList
$friendList is a string like: ($userId,2343),($userId,dfgdf),($userId,67567),…
and than use
SELECT userId FROM users LEFT JOIN friends ON users.userId=friends.userId
b)
UPDATE users SET friends=$friends
$friendList is a string like: 34534,7634,3456346,834463
and than use
$friends=$db->get_var("SELECT friends FROM users WHERE userId=$userId");
SELECT userId FROM users WHERE userId IN ($friends);
If I use the option a), table friends will be really huge (considering almost every user has more than 200 friends). So which one do you think is better for perfromance?