Keep a friend table that holds the UserID and then the UserID of the friend (we will call it FriendID). Both columns would be foreign keys back to the Users table.
Somewhat useful example:
Table Name: UserColumns: UserID PK EmailAddress Password Gender DOB LocationTableName: FriendsColumns: UserID PK FK FriendID PK FK (This table features a composite primary key made up of the two foreign keys, both pointing back to the user table. One ID will point to the logged in user, the other ID will point to the individual friend of that user)
Example Usage:
Table User--------------UserID EmailAddress Password Gender DOB Location------------------------------------------------------1 bob@bob.com bobbie M 1/1/2009 New York City2 jon@jon.com jonathan M 2/2/2008 Los Angeles3 joe@joe.com joseph M 1/2/2007 PittsburghTable Friends---------------UserID FriendID----------------1 21 32 3
This will show that Bob is friends with both Jon and Joe and that Jon is also friends with Joe. In this example we will assume that friendship is always two ways, so you would not need a row in the table such as (2,1) or (3,2) because they are already represented in the other direction. For examples where friendship or other relations aren't explicitly two way, you would need to also have those rows to indicate the two-way relationship.