I have two tables, Users and People, both of which share a common attribute, email address, of which they should be allowed to have many email addresses.
I can see three options myself:
-
One link table with redundant columns:
- Users [id,email_id] and People [id,email_id]
- EmailAddress [id,user_id,person_id,email_id]
- Emails [id,address,type]
-
Two link tables without redundancies:
- Users [id,email_id] and People [id,email_id]
- PersonEmail [id,person_id,email_id]
- UserEmail [id,user_id,email_id]
- Emails [id,address,type]
-
No link tables with redundant columns:
- Users [id] and People [id]
- Emails [id,address,type,user_id,person_id]
Does anyone have any idea what would be the best option, or if there is any other ways? Also, if anyone knows how to implement or feel it is better to have link tables without the generated id column please also specify.
Update: a User has many People, a person belongs to a User
First off, the relationship between user and e-mail is 1:N, not M:N, so in any case you don’t need the “link” table
EmailAddress.You need to decide which of these possibilities is true for your application:
Option 1:
Assuming the option (1) is the correct one, the logical model should look like this:
The symbol between Person and User is “category”, which at the level of the physical database can be implemented either:
PersonandUser,If you have…
…choose the implementation strategy with two tables.
If there are:
…choose the implementation strategy with the single table.
Similar analysis can be done for each of the remaining possibilities…
Option 2:
Option 3: