user3223372
user3223372

Reputation: 43

How do I make a many to many relationship in database?

I want to make a fleet management program for the car in my organization, but in erd diagram I face problem I have two table

Driver table Diver No, Name,Address, Car No

Car table Car No,Driver No

I want to make design many to many relationship means one car can drive by many drivers and one driver can drive more cars. My question how I represent this relation in the database and interface (meaning are I make a table to driver and table to car only in case that relation is many to many or what I do )

Upvotes: 1

Views: 197

Answers (1)

Liath
Liath

Reputation: 10191

Create a DriverCar table which contains both DriverID and CarID and foreign keys to the appropriate tables.

Depending on your data access model you can either use a clustered PK or create a separate identity column.

Any other data (such as how long each driver has spent in each car) would be logged against this table.

Upvotes: 1

Related Questions