Im trying to add a constraint to a reservation table, the reservation can either be for a flight or accommodation or both.

- First 4 records booked inward flight, outward flight and accommodation
- Next 4 records booked a flight only and have
acc_idset toNULL - Following 2 records booked only accommodation, hence in flight, out flight and seats are set to null.
Here are my constraints for this table
ALTER TABLE HOLIDAY_RESERVATION ADD CONSTRAINT HOLIDAY_PK PRIMARY KEY (RESV_ID);
ALTER TABLE HOLIDAY_RESERVATION ADD CONSTRAINT CUSTOMER_FK FOREIGN KEY (BOOKING_CUS_ID) REFERENCES CUSTOMER (CUS_ID);
ALTER TABLE HOLIDAY_RESERVATION ADD CONSTRAINT STAFF_FK3 FOREIGN KEY (EMP_ID) REFERENCES STAFF (EMP_ID);
ALTER TABLE HOLIDAY_RESERVATION ADD CONSTRAINT FLIGHT_FK FOREIGN KEY (IN_FLIGHT_ID) REFERENCES FLIGHT (FLI_ID);
ALTER TABLE HOLIDAY_RESERVATION ADD CONSTRAINT FLIGHT_FK1 FOREIGN KEY (OUT_FLIGHT_ID) REFERENCES FLIGHT (FLI_ID);
ALTER TABLE HOLIDAY_RESERVATION ADD CONSTRAINT ACC_FK FOREIGN KEY (ACC_ID) REFERENCES ACCOMMODATION (ACC_ID);
and the only constraint that is yielding an error is;
ALTER TABLE HOLIDAY_RESERVATION ADD CONSTRAINT FLIGHT_FK1 FOREIGN KEY (OUT_FLIGHT_ID) REFERENCES FLIGHT (FLI_ID);
I get
ERROR at line 1:
ORA-02298: cannot validate (U1146815.FLIGHT_FK1) - parent keys not found
What seems to be the problem? i understand that it has to do with orphan childs, but i am setting nulls so i dont understand, please advise
The error indicates that the
FLIGHTtable does not have an entry for at least one of theFLI_IDvalues between 11 and 18. You’d need to insert a row in theFLIGHTtable for whatever flights are missing or update your table to have a differentOUT_FLIGHT_ID.