As reported: Wayfair technical assessment, round 1 (screening, 2025): four design and concept questions; this was one of them.
You are building a Facebook clone. Next to every post, the page shows the author's current number of friends:
Marie McWilliams (105 friends)
The data lives in two tables:
USER USER_RELATIONSHIP
user_id PK friendship_id PK
name user1_id (indexed)
created_date user2_id (indexed)
start_date
Focusing on the database, how would you implement the friend-count feature so that it scales to more users than Facebook has?