Is it possible to have a table with the columns user_id and friends and store the user id's of all of the users a user is friends with? Or is it better to have a row for every "relationship" in the friends table? What is more practical?
1 Answer
It depends a little on how you intend to use it, but usually, yes, you'd want a row for each relationship for easier querying of those individual relationships ("how many people are friends with Bob", "how many friends does Jane have total", etc.).
1 Comment
Blake
Agree. In order to see "Who is friends with Jane?" and all friends were stored in a serialized array or text string, you would have to evaluate your entire database. With individual relationships, you can just query specifically for that relationship.