I have two tables, 'booking' and 'isBooked'. I want to add values to the isBooked table. But i keep getting an error "Cannot add or update a child foreign key constraint fails".
CREATE TABLE booking (
bookingID INT AUTO_INCREMENT,
customerID INT,
startDate DATE,
endDate DATE,
dateBookedOn TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
employeeID int,
PRIMARY KEY (bookingID),
INDEX idx_start (startDate),
INDEX idx_end (endDate),
FOREIGN KEY (customerID) REFERENCES customer(CustomerID)
);
CREATE TABLE isBooked(
BookingID int,
DogID int,
RunID int,
foreign key (RunID) references Run(RunID),
foreign key (DogID) references Dog(dogID),
foreign key (BookingID) references Booking(BookingID)
);
insert into isbooked values(1, 1, 1);
can anyone tell me why this error appears when trying to insert values to 'isBooked'.