HubSpot Interview Question

How would you model friendships and relationships in a database?

Interview Answer

Anonymous

Jan 25, 2019

Define a table that would hold records for Person A, Person B, ... Person N and another table for Relationships. Store two records for each relationships with columns specifying whom requested the friendship and who approved. You can search then for Person A and return all of the relationships for that Person.