0

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 1

4

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.).

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.