Database design: Best table structure for capturing the User/Friend relationship?

Zachary Yates picture Zachary Yates · Dec 18, 2008 · Viewed 58.7k times · Source

I'm trying to design a data model that denotes one user being the friend of another user. This is what i've come up with so far, but it seems clunky, is there a better solution?

User
=====
Id
Name
etc...

UserFriend
===========
UserId
FriendId
IsMutual
IsBlocked

Answer

chaos picture chaos · Dec 18, 2008
UserRelationship
====
RelatingUserID
RelatedUserID
Type[friend, block, etc]

Agree that mutuality doesn't belong as a column; breaks normalization.