Reputation: 10577
if I have tables like this:
GROUP(**GID**, DESC) -- GID IS PK
USER(**UID**, FIRST, LAST, GID) -- UID IS PK, GID IS FK
A group can have multiple users but a user can belong to only one group.
How would I enforce rule so that an employee can belong only to one department?
Much appreciated
Upvotes: 0
Views: 33
Reputation: 44891
With eid
as a primary key you won't be able to insert more than one row for any employee as that would violate the primary key constraint. So there's no way an employee could ever belong to more than one department the way your tables are modeled.
Upvotes: 2