473,692 Members | 2,216 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 2910
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*********@gm ail.comwrote in message
news:ed******** *************** ***********@m34 g2000hsc.google groups.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...@gm ail.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
1602
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 CLIENT-B came along and and requested the same application but with little bit different requirements (both in terms of the front-end and back-end processing), so we had to create a new application for that client. Now came CLIENT-C !!!!!! I am...
5
6249
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++ with my defined classes to be added to linked list structure so as to facilitate the operation of all instances of defined classes. Is that possible to apply such classes to <list> or <Vector> structure? Thanks!
3
1739
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: www.oursite.com/Jack www.oursite.com/Sue www.oursite.com/Tom
1
2665
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 access insert, update delete and select. Let me explain clearly For example think we are using asp/asp.net website
2
1256
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 server 2000 to store user database. Problem is if user clsoes the browser then how can I check and clear the session? wiating for your reply
3
1721
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 the data class (they match various sources such as a text file or a database, and then fill the data). The filling methods use the 'setter' methods of the data class, but then I want to present the data class to the outside world (i.e. other
8
1695
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 populations with different access rights and "roles" will be visiting the site. I will be using ASP.NET 2.0's membership, roles, and profiles stuff to manage access. User controls need to be visible or not visible depending on user role. In some...
1
1152
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
1713
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 i came through this article http://articles.techrepublic.com.com/5100-6350_11-5287638.html and before i proceede i must tell you that iam using win xp professional sp2 where were given two main and very first step before you start making your...
0
8604
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9083
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8961
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8801
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6459
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5819
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4324
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.