tags:

views:

38

answers:

1

Need your help to get the list of suggested friends (who aren't friends of the current user but are friends of 2 or more of the current user's friends). The primary ordering should put people at the same school at the top, and the secondary ordering should put people with more common friends (that is, the number of people who are friends of that person and the current user) near the top.

Users: user_id PK, user_name

Profiles: user_id PK, school_name, ...

Friendships: id PK, user_id FK, friend_id FK

Thank you in advance.

Joe

This is not a homework question. I am currently working on a site and my solution seems not efficient enough. That's why I need you suggestions. Thanks.

A: 

(I'm assuming HW here.)

Seems like if you queried for a list of all of your friends' friends, and checked for the friends-of-friends that weren't unique in that list, you'd be getting somewhere.

John at CashCommons