How would a set of related values be stored together in a MySQL db?
For example, if I wanted to store a user's buddy list, then the way I can think of would be something like this:
user | friend
John | Jim
John | Bob
John | Amy
Bob | Jim
Bob | Amy
So John's friendlist would include Jim, Bob, and Amy, and Bob's friendlist would include Jim and Amy. But it seems really inefficient to create a new row every time a new entry in the list is needed
I want to be able to store values like this:
user | buddylist
John | Jim,Bob,Amy
Bob | Jim,Amy
What would be the most efficient way to do this?
For example, if I wanted to store a user's buddy list, then the way I can think of would be something like this:
user | friend
John | Jim
John | Bob
John | Amy
Bob | Jim
Bob | Amy
So John's friendlist would include Jim, Bob, and Amy, and Bob's friendlist would include Jim and Amy. But it seems really inefficient to create a new row every time a new entry in the list is needed
I want to be able to store values like this:
user | buddylist
John | Jim,Bob,Amy
Bob | Jim,Amy
What would be the most efficient way to do this?
Comment