If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > members and friends (was "Design Question")

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-24-06, 17:12
gsxraddict gsxraddict is offline
Registered User
 
Join Date: Jun 2006
Posts: 2
members and friends (was "Design Question")

Say I have 10000 + members in my database

Each member could have 0 - 10000 friends.

What is the best way to store this information
I can create a table called "friends"

Then when someone adds a friend, his and the friends name is added to the database.

Then I could do a sql search to find the user and his friends....

But when he has 200 friends, his name would be added to the database 200 times with a different friend in each row. I could return all these friends easily, but the problem is. I don't think it would be effective haven't the same user with a different friend listed 200 times.
It just doesn't seem like practical database design to me.

Can anyone give me some advice?
Reply With Quote
  #2 (permalink)  
Old 06-24-06, 18:56
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the method you have described (a table with 2 ids, the user and the friend) is the "best practice" design

yes, this will result in rows that look like this

100 212
100 331
100 352
100 756
200 175
200 823

but this is actually fully normalized and the simplest and most efficient way to do it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-24-06, 19:08
gsxraddict gsxraddict is offline
Registered User
 
Join Date: Jun 2006
Posts: 2
thank you alot!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On