Buddy List: Relational Database Table Design
- by huntaub
So, the modern concept of the buddy list:
Let's say we have a table called Person. Now, that Person needs to have many buddies (of which each buddy is also in the person class). The most obvious way to construct a relationship would be through a join table.
i.e.
buddyID person1_id person2_id
0 1 2
1 3 6
But, when a user wants to see their buddy list, the program would have to check the column 'person1_id' and 'person2_id' to find all of their buddies.
Is this the appropriate way to implement this kind of table, or would it be better to add the record twice.. i.e.
buddyID person1_id person2_id
0 1 2
1 2 1
So that only one column has to be searched.
Thanks in advance.