I'm working on a "people you may know" feature. I have two tables:
USERS
id
email
name
etc
FRIENDSHIPS
user_id
friend_id
For each friendship I make two records. Say users 7 and 9 become friends... I would make a record where user_id=7,friend_id=9 and another where user_id=9, friend_id=7 in the friendships table.
How would I make a sql query that suggests people I'm likely to know based on friends of my friends? I also want it ordered based on the most mutual friends.