[Typo3-dev] community extension buddy list

Christoph Koehler christoph.koehler at gmail.com
Sun Dec 11 06:17:33 CET 2005


Hey list,

I am trying to make a decision and find a good way of doing something.
In a community extension that has a friends list, I would like to make it  
so that if someone adds someone else as friend, they show up on each  
others friends list, instead of people having you on their list but not  
vice versa. Hope that makes sense.

Now, I was wondering, how would that look stored in the db and in code?
I find myself wanting to just store both in a table like so:

table: buddylist
field: buddy1
field: buddy2

Now, all my queries on that db will have to make up for different  
situations: If the person initiating the adding is always buddy1, then in  
some rows user uid=1 will be in field buddy1, other times in buddy2. So  
all my queries will have to look like so:
SELECT * FROM buddylist WHERE buddy1=1 OR buddy2=1

And this is just for retrieving friends. If I want to check if someone is  
friends with someone else, the query would look like so:
SELECT * FROM buddylist WHERE (buddy1=1 AND buddy2=2) OR (buddy1=2 AND  
buddy2=2)

All this seems to be a lot of hassle for something so simple.
Would you guys prefer to have rows for each friend-friend relationship? So  
that there will be rows like this:

row1: buddy1 = uid 1 buddy2 = uid 2
row2: buddy1 = uid 2 buddy2 = uid 1

This seems to generate a lot of duplicate information in the db (and  
that's how cwt_community does it, but it also allows non-mutual friends)

How do you guys think this should be done best?

Thanks!

Christoph




More information about the TYPO3-dev mailing list