473,503 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User and friends database structure

Hi all

I've got the following problem in my database structure : I have a
table "User". Each user can have one or more friends which are users
too. And I have no idea about the way I must think my structure. My
first idea was to create a second table "User2" which would be an
exact copy of the table "User", but I can't because of the fact that
an user can have several friends...

The best way would be to store friends in a collection, and store this
collection in a field of the table "User". But I have no idea about
the way to do that (if it's possible).

So, do you have another solution ?

Thanks in advance
Mar 12 '08 #1
2 2896
Put all the users (including friends) into one table.

The way to link them depends on the kinds of relationships that exist
between them. If they are directional relationships (User 1 has user 2 as a
friend, but that does not imply that user 2 has user 1 as a friend), the 2nd
table would have these fields:
UserID Number relates to the primary key of tblUser
FriendID Number relates to the primary key of tblUser

The combination of the 2 fields together would be primary key in this 2nd
table.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"LeXave" <fr*********@gmail.comwrote in message
news:ed**********************************@m34g2000 hsc.googlegroups.com...
>
I've got the following problem in my database structure : I have a
table "User". Each user can have one or more friends which are users
too. And I have no idea about the way I must think my structure. My
first idea was to create a second table "User2" which would be an
exact copy of the table "User", but I can't because of the fact that
an user can have several friends...

The best way would be to store friends in a collection, and store this
collection in a field of the table "User". But I have no idea about
the way to do that (if it's possible).

So, do you have another solution ?

Thanks in advance
Mar 12 '08 #2
On Mar 12, 2:27*am, LeXave <frharkon...@gmail.comwrote:
Hi all

I've got the following problem in my database structure : I have a
table "User". Each user can have one or more friends which are users
too. And I have no idea about the way I must think my structure. My
first idea was to create a second table "User2" which would be an
exact copy of the table "User", but I can't because of the fact that
an user can have several friends...

The best way would be to store friends in a collection, and store this
collection in a field of the table "User". But I have no idea about
the way to do that (if it's possible).

So, do you have another solution ?

Thanks in advance
tblUser
userId (pk)
name
address
etc

tblFriend
userId (fk to tblUser.userId)
friendId (fk to tblUser.userId)
Mar 12 '08 #3

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

Similar topics

1
1592
by: Stewart Rogers | last post by:
Hi all, I have been working on an ASP.NET application that is a kind of wizard ( a list of sequential pages ). We built that application for the CLIENT-A and it worked fine. After six months...
5
6218
by: Kenneth | last post by:
<list> seems to be a powerful structure to store the related nodes in memory for fast operations, but the examples I found are all related to primitive type storage. I'm doing a project on C++...
3
1730
by: Amir Eshterayeh | last post by:
Dear Friends Would you please give me your professional idea about this asp.net problem. I need different virtual directory for different customer with their names like these:...
1
2659
by: Friends | last post by:
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to...
2
1249
by: _thedebugger | last post by:
Dear friends, I am developing one shopping cart application. My requirement is if user logged in one machine, he should not logged into from another db. how should I do that. I am using sql...
3
1707
by: shaun roe | last post by:
Hello, I am working in a framework with certain restrictions; in particular I have a 'data' class with getter and setter methods, and a some 'filling' classes which know how to insert the data to...
8
1685
by: | last post by:
I'm looking for some design guidance on a collection of projects I'm working on. The project involves a bunch of websites constructed out of a collection of user controls. Different user...
1
1136
by: Aryan | last post by:
Hi Friends, I wanted to know, how Master Page is different then Web User Control?? Thanks & Regards, Manoj Singh
4
1701
omerbutt
by: omerbutt | last post by:
hi every one I am A new Bee to php mysql and i was surfing through the net to learn about how to secure the mysql when you are working in a web environment while working with php html and javascript...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
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
7319
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...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.