I\'ve run into the same problem in two different pieces of work this month:
Version 1: User 1 & User 2 are friends
Version 2: Axis 1 & Axis 2 when gr
"x is a friend of y".
Define a table of (x,y) pairs and enforce a canonical form, e.g. x Create a view as SELECT x,y FROM FRIENDS UNION SELECT x as y, y as x FROM FRIENDS. Do your updates against the base table (downside : updaters must be aware of the enforced canonical form), do your queries against the view.