Hacker News new | past | comments | ask | show | jobs | submit login
Modeling mutual friendship (minimalmodeling.substack.com)
30 points by evilsimon 3 days ago | hide | past | favorite | 2 comments

I definitely thought this would be philosophical, not technical, based on the title, and I got excited. "Modeling mutual friendship" is definitely something I want to do for my kids, for example.

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.

Applications are open for YC Winter 2022

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact