torayeff
torayeff

Reputation: 37

Contacts Database

everybody. I want to develop online contacts book for mobile phones. But I have the problem with database management. For example I have user, he/she has username, password, email, phone number, etc... Also this user has contacts whom he/she accepted as friends. How can I store contacts for each user effectively? I think I can create new table for each new user but it is not effective. Can anyone suggest anything, or give any link, resource about this problem?

Upvotes: 0

Views: 287

Answers (2)

yaniv
yaniv

Reputation: 1003

What need to do is to create one table for contacts and add a column name UserID. the primary key will be "UserID, ContactID".

When you add a new contact you also put the UserID that added the contact.

Now you can tall which contact belong to what user.

Upvotes: 0

refaelos
refaelos

Reputation: 8075

Create a "friends" table with many-to-many relationship with the "contacts" table. That table will have 2 columns: "contact-id" and "friend-id". Both columns together are the primary key of that table.

Upvotes: 2

Related Questions