Why can’t this entry be added because of Foreign Key error?

When you try to insert this record:

INSERT INTO ROUTE VALUES ('7418','66','200','313');

You are assuming that there is a value in DELIVERY with a VEHICLE_VEH_ID value of '200' and a DELIVERY_DRIVER_DR_ID value of '313'. There error is telling you that there is no such record in that table.

A foreign key constraint means that the column(s) with that constraint is/are constrained to only point to valid records in the foreign table. (In this case DELIVERY.) Such a record must exist in that table before you can insert a dependent record in this table.

Leave a Comment