probuly sounds like noobish! or silly but what i would do is have a new
table with 2 colums the first will be a login id and the second will be
a login id
and i would just do like ...
id1 id2
John Joe
John Alex
John Fred
Joe Fred
Fred Alex
would mean John as Alex, Fred and Joe as his friends
Joe has Fred as a friend
and Fred had Alex as a friend
and would just do like
SELECT `id2` FROM `freiends` WHERE `id1` = 'John';
to get all of Johns friends
and
SELECT `id1` FROM `friends` WHERE `id2` = 'Fred';
to get people that had fred set as their friends
and just work around that, of cause you can have id or account numbers
and not names, can anybody see any problems with that ?
Martin Gallagher wrote:
"of course you have the problem where john has Joe as a friend but Joe
doesn't have john as a friend. This seeming inconsistency, may or may not
be a problem depending on exactly what kind of a relationship you are trying
to define."
You've just hit the nail on the head! That's exactly the problem.
I think I might just have to grin and bear what I already have :-(
-----Original Message-----
From: 2wsxdr5 [mailto:[EMAIL PROTECTED]
Sent: 07 April 2006 15:11
To: Martin Gallagher; mysql@lists.mysql.com
Subject: Re: Social Network, linking members
Martin Gallagher wrote:
Hi,
I'm trying to find the most efficient way of "linking" members to one
another in a social networking application.
Currently I link them using 2 separate fields for the members: id1, id2.
So,
to find people in your network you would do:
I'm not sure exactly what it is you are doing but I think this may be
it. You have a table of people and you want to know who is friends with
who. I know 'friend' may not be the best term to use but it is easier
to type. So I have my people table.
People{
*PID,
Name,
. . .
}
Then the Friend Table,
Friend{
*PID,
*FID
}
If you have person, John, with ID 234, and you want to know all his
friends you can do this...
SELECT f.FID, p.Name
FROM Friend f JOIN People p ON f.FID = p.PID
WHERE f.PID = 234
of course you have the problem where john has Joe as a friend but Joe
doesn't have john as a friend. This seeming inconsistency, may or may
not be a problem depending on exactly what kind of a relationship you
are trying to define.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]