What is the best friend-list table design (for performance)? Probably there should not be many rows for every frienship. What Facebook and Myspace is doing? (in MySQL)
Assuming you have a separate users table, it would just be a table where each row has two user ids (e.g., user, friend) and possibly a third column to indicate the strength of the relationship (BFF, acquaintances, etc). You can add unique constraints to make sure you don't have duplicates where the same pair is saved as (user, friend) and (friend, user).
mY CURRENT FRIEND TABLE STRUCTURE
————————————————
frnd_id | user_id | frnds |
————————————————-
The first column saved the auto generated id. the next column “user_id” saves the value of the user and the last column saves the string with IDs of other users containing “|” as a separator. I was able to search users though and was also able to add them to a user. But the problem starts when user searched and I’m unable in not showing user the same friends that he has in his list.
Please suggest me a better option. IS MY DATABASE STRUCTURE CORRECT?