myspace type DB for managing friends

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

myspace type DB for managing friends

Post by GeXus »

I'm working on a project that will have a similar DB to how myspace manages friends.

I'm trying to determine the best way to build this out, as one user could potentially have hundreds of thousands of friends...

Would it be best to create an ID table that simply holds the UserID and the UserID of the friend? OR would it be best to just use longtext and hold all friends UserIDs in an array for a paticular user?

Any help would be great... thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Never use longtext (or any similar storage type) to hold multiple references.

The former is preferred.
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

feyd wrote:Never use longtext (or any similar storage type) to hold multiple references.

The former is preferred.
With creating an ID table there could potentially be millions of records really... is that really the most efficient way?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It is the correct way and most flexible way. With a longtext you have a VERY finite amount of references to users. Depending on how they are stored, the number available would literally vary because some identifiers are longer than others.. user 123 vs user 123456 for example.
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Gotcha! Thanks alot :)
Post Reply