473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Implementing a BUDDY list

I am creating a web community site where each user can have a list of
buddies. I have struck a bit of a problem though.
I am designing my db model and have two entities called users
containing usual stuff like password, name... and I have Buddy List.
I also have the following relation.

Users "have a" Buddy List

The cardinality is that a user can have one buddy list and one buddy
list is associated with one user.

However a buddy list contains MANY users and a single user can be in
MANY buddy lists. So do I have a many-to-many relationship? To further
confuse matters as a Buddy List is actually just a list of users is
this a recursive relationship?

Im really confused, any help welcomed!!!
Jul 19 '05 #1
4 2995
you need 2 tables. A user table (as you have described) and a buddy table
with basically 2 columns. UserID, BuddyID.
So if user 2 has buddies 4,5,8, 17 then there would be 4 rows in the buddy
table
2,4
2,5
2,8
2,17
to list 2's buddies
select * from buddy where UserID=2. (gives you id's of 2's buddies)
or select * from buddy left join users using (UserID)
or select user.name as Uname from buddy left join users using (UserID) and
the Uname(s) are 2's buddies.
dp
I am creating a web community site where each user can have a list of
buddies. I have struck a bit of a problem though.
I am designing my db model and have two entities called users
containing usual stuff like password, name... and I have Buddy List.
I also have the following relation.

Users "have a" Buddy List

The cardinality is that a user can have one buddy list and one buddy
list is associated with one user.

However a buddy list contains MANY users and a single user can be in
MANY buddy lists. So do I have a many-to-many relationship? To further
confuse matters as a Buddy List is actually just a list of users is
this a recursive relationship?

Im really confused, any help welcomed!!!

Jul 19 '05 #2
you need 2 tables. A user table (as you have described) and a buddy table
with basically 2 columns. UserID, BuddyID.
So if user 2 has buddies 4,5,8, 17 then there would be 4 rows in the buddy
table
2,4
2,5
2,8
2,17
to list 2's buddies
select * from buddy where UserID=2. (gives you id's of 2's buddies)
or select * from buddy left join users using (UserID)
or select user.name as Uname from buddy left join users using (UserID) and
the Uname(s) are 2's buddies.
dp
I am creating a web community site where each user can have a list of
buddies. I have struck a bit of a problem though.
I am designing my db model and have two entities called users
containing usual stuff like password, name... and I have Buddy List.
I also have the following relation.

Users "have a" Buddy List

The cardinality is that a user can have one buddy list and one buddy
list is associated with one user.

However a buddy list contains MANY users and a single user can be in
MANY buddy lists. So do I have a many-to-many relationship? To further
confuse matters as a Buddy List is actually just a list of users is
this a recursive relationship?

Im really confused, any help welcomed!!!

Jul 19 '05 #3
thanks a lot!
Jul 19 '05 #4
thanks a lot!
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David | last post by:
I am creating a web community site where each user can have a list of buddies. I have struck a bit of a problem though. I am designing my db model and have two entities called users containing...
3
by: Cary Linkfield | last post by:
I have created a custom class inheriting CollectionBase and implementing IBindingList. I am binding the list to a datagrid. I would like to have a property on the class that works like the...
8
by: Ben | last post by:
Hi all, I implemented a stack in C++ in 2 different ways and I'd like to know which approach is better than the other.. and if there is any difference between the two? I'd also like to know if...
3
by: bharmaji | last post by:
Hi I am wondering if there is freely available code for a buddy memory allocator. Specifically I am looking for code that will can break the blocks across multiple levels and then merge them back...
9
by: raylopez99 | last post by:
What's the best way of implementing a multi-node tree in C++? What I'm trying to do is traverse a tree of possible chess moves given an intial position (at the root of the tree). Since every...
11
by: fhk6431 | last post by:
Hey.. Anybuddy interested in working software development for big company.. My company is hiring people aggresively. Contact me ASAP at fhk6431@gmail.com You must be good in C !! right :)...
0
by: koonda | last post by:
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my...
4
by: zacks | last post by:
Most applications whose purpose is to work with various types of files implement a "Most Recent Files" list, where the last, say, four files accessed by the application can quickly be re-opened by...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.