News for hackers. Stuff that matters.
Re:Modeling mutual friendship by allknowingfrog on Wednesday July 21, 2021 @11:34AM (#27907676)
I've run across this problem before and ultimately decided on the two-record solution. I reasoned that it's entirely possible to have a non-mutual friendship. The table ends up having a "user_id" and a "friend_id", with each record indicating that one user considers another to be a friend. A "friend request" can even be modeled as a single record, in which case, accepting the request creates the matching entry. The concept of "mutual" friends determines whether two users are connected and visible to one another.

There are no comments on this comment yet.