social graph

Hi I'm trying to build a new facebook app. I want to keep a database of the friends of friends for each user. what's the best way to store and maintain such a graph ?

thanks Gady

Hi Gady,

There was an interesting article in February's edition on Linux Journal (166) about Rails and Facebook API integration. http://www.linuxjournal.com/article/9924

They suggested a few of resources http://wiki.developers.facebook.com/index.php/Using_Ruby_on_Rails_with_Facebook_Platform http://rfacebook.rubyforge.org/ http://www.chadfowler.com/2007/9/5/writing-apis-to-wrap-apis

Cheers, Ewan

Gady Sujo wrote:

Hi I'm trying to build a new facebook app. I want to keep a database of the friends of friends for each user. what's the best way to store and maintain such a graph ?

I imagine if you have a table of just the friends of each user (columns: user_id, friend_user_id), you can get the collection of friends of friends of each user.

Something like:

select   u.* from   user u,   friends f1,   friends f2 where   f2.user_id = :given_user_id and   f2.friend_user_id = f1.user_id and   f1.friend_user_id = u.id and

Stephan