Reputation: 153
I'm new in databases so it's been a little bit hard to understant certain things.
My main doubt it's about one situation.
A (stupid) example:
I have one table for President and other table for Elections.
President: PresidentID Name DateOfBirt ...
Election: ElectionID DateOfElection ...
A President can go to many Elections, as long they are from different Countries.
What's the design of new table(s) that I have to make?
Sorry if this is very simple, but I don't see how to solve this.
Upvotes: 2
Views: 286
Reputation: 171559
ElectionPresident
------------------
PresidentID <--PK, FK to President
ElectionID <-- PK, FK to Election
to address the country issue, you could do:
ElectionPresident
------------------
PresidentID <--PK, FK to President
ElectionID <-- PK, FK to Election
CountryID <-- FK to Country
and have a unique index on (PresidentID, CountryID)
Upvotes: 2