in reply to Re: best way to keep track of who's friends with whom
in thread best way to keep track of who's friends with whom

To make sure you don't double add friend pairs you would need a rule for deciding which of any two friends goes in the first key field and which goes in the second key field.
...assuming that friendship is commutative. (i.e., "If Alice likes Bob, then Bob likes Alice.") If it's directional, as on LiveJournal or Twitter, then this would not apply, since "Alice likes Bob" and "Bob likes Alice" are independent of each other.
  • Comment on Re^2: best way to keep track of who's friends with whom

Replies are listed 'Best First'.
Re^3: best way to keep track of who's friends with whom
by bart (Canon) on Oct 05, 2009 at 17:24 UTC
    Totally agreed.

    In case you do want to treat friendship as commutative, here's a simple rule: require that the value of the id A is numerically smaller than the value of id B. If it's the other way around, swap them.