You need three tables - User
, Interest
and an associative table for the many-to-many relation between them (a User
can have many Interest
s and an Interest
will have many User
s), call it UserInterestLink
or something. User
and Interest
will have autoincrement int
fields as a surrogate primary key, UserInterestLink
will have FKs to both User
and Interest
, like so:
|=================================================|
| TABLE: User |
|=================================================|
| Name | Type |
|=================================================|
| UserID | int, autoincrement, PK |
| << Other User fields here >> |
|=================================================|
|=================================================|
| TABLE: Interest |
|=================================================|
| Name | Type |
|=================================================|
| InterestID | int, autoincrement, PK |
| << Other Interest fields here >> |
|=================================================|
|=================================================|
| TABLE: UserInterestLink |
|=================================================|
| Name | Type |
|=================================================|
| InterestID | int, FK to Interest.InterestID |
| UserID | int, FK to User.UserID |
|=================================================|
I didn't mention the PK on UserInterestLink
, for efficiency it would be a compound PK on (UserInterestLink.InterestID, UserInterestLink.UserID)
, but there's also an argument to be made for a seperate surrogate primary key (which I personally think is a waste of space, unless you need to allow for multiple UserInterestLink
s between one User
and one Interest
). For a purely associative table in a many-to-many relationship, though, the compound primary key should work fine.
Edit: The complicated part of this isn't in the relational design, it'll be in the application code, because you'll need best-match/partial matching in order to show users the groups that most closely match their interests (rather than having accidental splinter groups all over the place). And if you want to out-Facebook Facebook, you'll need a smoother and better user experience than they offer.