I don't recommend this approach because if you want to know all user 1
friends yo must do something like
user_id_1=1 or user_id_2=1 and thats an overhead (and you need two indexes
for that)

if you have something like:

Table friends:
id   user1_id user2_id
1       1            2
1       2            1
2       5            2
2       2            5
3       3            1
3       1            3
4       4            1
4       1            4
5       2            4
5       4            2

you can do  user_id_1=1 (only one index)

Regards

Pablo Viojo
[email protected]
http://pviojo.net

¿Que necesitas?
http://needish.com


On Thu, Aug 27, 2009 at 2:48 PM, DigitalDude
<[email protected]>wrote:

>
> Hey,
>
> ah ok I think we both mean the same thing, but I forgot that the
> relation is not only by one side, but by two sides.
>
> So a simple example would look like this:
>
> Table friends:
> id   user1_id user2_id
> 1       1            2
> 2       5            2
> 3       3            1
> 4       4            1
> 5       2            4
>
> This would mean:
>
> User 1 is a friend of: 2, 3 and 4
> User 2 is a friend of: 1, 4 and 5
> User 3 is a friend of: 1
> User 4 is a friend of: 1 and 2
> User 5 is a friend of: 2
>
> Is that correct? I think it is...?
>
>
>
> On 27 Aug., 18:33, Miles J <[email protected]> wrote:
> > Not necessarily. If you are doing a friend system, the table would
> > look like so:
> >
> > friends: id, user1_id, user2_id
> >
> > And 1 row would be for both user1 and user2, instead of adding 2 rows
> > for each user.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to