What is the best way to store user relationships, e.g. friendships, that must be bidirectional (you\'re my friend, thus I\'m your friend) in a rel. database, e.g. MYSql?
<
You could check which of the two user_id's is the lowest and store them in a specific order. This way you don't need double rows for one friendship and still keep your queries simple.
user_id_low | user_id_high
a simple query to check if you're already friends with someone would be:
Or you could find the lowest/higest userid using mysql
And to get all your friends id's