Reputation: 136
I have two tables:
Table Shop
idShop
shopName
idManager??
Table ShopManager
idManager
managerName
idShop??
I want to create a foreign key between these two tables. But I have a design issue:
Each Shop can have different ShopManagers and a ShopManager could work in every shop.
How can I solve it?
Upvotes: 0
Views: 31
Reputation: 1390
You have two options.
id idManager idShop
1 5 6 2 5 2 3 5 9
Upvotes: 1
Reputation: 436
I'd consider creating an "assignment" table that consists of a ShopManager ID and a Shop ID. That way, multiple ShopManagers can be assigned to a single Shop, and multiple Shops can be assigned to a single ShopManager. The relationship between Shop and the assignment table would be one Shop to zero to many assignments, and the relationship between ShopManager and the assignment table would be one ShopManager to zero to many assignments.
Upvotes: 1