I am doing data modelling on MySQL workbench.
I have three data entities:
company
driver
car
Relationship is, one company has many drivers, one car has two drivers (main driver and co-driver)
This is the data model I have so far (I only created one driver
link to car
in the picture):
As above image shows, I linked company
to driver
with one-to-many relationship. The tool automatically creates company_id
foreign key in driver
table as expected. No problem there.
Problem comes in the relationship between driver
and car
. In the picture, I only linked one-to-one relationship from car
to driver
, I expected the tool would create one driver_id
foreign key, but the tool automatically creates two foreign keys: driver_id
& driver_company_id
.
(If I create another one-to-one relationship for co-driver from car
to driver
, the tool would again create two new foreign keys, which is not indicated in the picture)
Why is that? Why does the tool create the driver_company_id
foreign key besides driver_id
foreign key for an one-to-one relationship? What is the concept behind? What would be the difference if now I manually delete the driver_company_id
foreign key?