sql - How to manage a contact relation in database -


i have create database schema manager user contacts. explain...

i have simple user table primary key (named id).

i have contact table having 2 foreign keys (senderid user, receiverid user) constituting primary key.

my problem if user send contact invitation user b, have following entry :

contact(a,b)

in case, can have entry contact(b,a) similar other entry.

how can manage case ?

thanks help.

i create 2 separate tables, 1 pending requests contactrequests(senderid, receiverid), , contact lists named contact(user_id,contact_id).

i store contact requests in contactrequests did , upon request validation, create 2 entries in contact this: contact(a,b) contact(b,a) , delete pending request. doing able user contact list independently sent request.

googling "many many relationship" design database.


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -