How to store bidirectional relationships in a RDBMS like MySQL?
问题 Suppose I want to store relationships among the users of my application, similar to Facebook, per se. That means if A is a friend(or some relation) of B , then B is also a friend of A . To store this relationships I am currently planning to store them in a table for relations as follows UID FriendID ------ -------- user1 user2 user1 user3 user2 user1 However I am facing two options here: The typical case, where I will store both user1 -> user2 and user2->user1 . This will take more space, but