Reputation: 2530
I have an existing website, that doesn't use any specific framework. This project is much older and is slowly being evolved, which is somewhat of a nightmare really.
Currently, I am trying to implement a better solution to current users to have 'assistants' to their accounts.
The current data resides like this (users & contacts tables):
**users table**
userId, email, password...
1 [email protected], pa$$word
2 [email protected], pa$$word
**contacts table**
contactId, userId, fName, lName...
1, 1, john, doe
I am trying to figure out how to modify my site to enable userId's (1&2), to be able to access this contact.
Instead of starting over, any direction or samples that I could glean from on how to solve this issue of mine? Any help would be greatly appreciated.
Upvotes: 0
Views: 26
Reputation: 51
Remove the userId column from the contacts table and create a new table contacts_users with two columns, contactId and userId.This is called a PIVOT TABLE and allows many-to-many relationships like what you are describing.
Upvotes: 1