I know that what I'm asking can't be done or shouldn't be done, but I really don't know how to do it. This is the problem:

2 tables:

 - Drivers (id_driver, name, etc...) 
 - Trucks (id_truck, model, id_driver,

The user will fill a form with the truck's info, but a truck may have more than one driver, and thats my problem. I don't know what to do there.

Thanks in advance.

  • Can a driver have more than one truck? Oct 22, 2014 at 16:57
  • Your requirement is very legit. This is where RDBMS shines. Oct 22, 2014 at 18:44

2 Answers 2


This is likely to be a many to many relationship.

create table drivers (
  driver_id int primary key,

create table trucks (
  truck_id int primary key,

create table drivers_trucks (
  driver_id int references drivers(driver_id),
  truck_id int references trucks(truck_id),

  primary key (driver_id, truck_id)

Swap the foreign key so that the Drivers table has id_truck. This way multiple drivers can be associated with the same truck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.