
Originally Posted by
DoubleDee

Originally Posted by
le moi
does it matter which of them does the requesting?
I don't follow you?!
if user 9 requests a friendship from user 37, you create a row in the table with 9 and 37 as requestor and requestee
if user 37 requests a friendship from user 9, you create a row in the table with 37 and 9 as requestor and requestee
so far, no prob
later, when you do a search, let's say for user 9's friends, your query will look like this:
Code:
WHERE requestor = 9 OR requestee = 9
that's going to be problematic because mysql cannot optimize that query, and will do a table scan
there are two ways around this, though
one is to split the WHERE clause and write two queries that are UNIONed
the other is to enter two rows into the table, where 9 and 37 are present twice, in two columns (although these cannot now be called "requestor" and "requestee" and you'll need to find another way to record who asked whom)
debbie, there are literally dozens of previous threads in the sitepoint forums on the friends relationship and how to store the data and retrieve/display it
i suggest that you read some of them
Bookmarks