what is the most efficient way to make a "contacts" table in mysql database.
like a user can change the relationship between him and another user.
like i cant figure out how the database should look to be most eficiant. ive been through two ways. the first was a column for every user and then a row for every user but that would be too much spaces. i only need to hold one field that shows the relationship between the users.
then i thot of having a row in the table for every person
one column would be like person1 then th next column would be person2 then the 3rd needed column would be relationship which would be set to 1 - 5 depending on the relationship of the user.
but that would be 2 rows for one relationship right?
is there another way>? thats easier db design?
SKANK!!!!!
5
Posting Pro in Training
Recommended Answers
Jump to PostWhat about storing the users(contacts) and the relationship details in separate tables and linking them using PK and FK.
Jump to PostThat depends on your requirement.
ex
USERS
----------
ID
FIRST_NAME
LAST_NAME
........
........
etcRELATIONSHIP
---------------------
R_ID
U1_ID
U2_ID
R_TYPE
R_DESC
........
........etc
Jump to PostYou can join the tables based on user ID in both the tables and retrieve the desired data.
All 11 Replies
debasisdas
580
Posting Genius
Featured Poster
SKANK!!!!!
5
Posting Pro in Training
debasisdas
580
Posting Genius
Featured Poster
SKANK!!!!!
5
Posting Pro in Training
debasisdas
580
Posting Genius
Featured Poster
SKANK!!!!!
5
Posting Pro in Training
debasisdas
580
Posting Genius
Featured Poster
SKANK!!!!!
5
Posting Pro in Training
debasisdas
580
Posting Genius
Featured Poster
SKANK!!!!!
5
Posting Pro in Training
debasisdas
580
Posting Genius
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.