CREATE TABLE orders (
orderID PRIMARY KEY,
customerID NOT NULL
REFERENCES customers (customerID),
orderDate NOT NULL
)
CREATE TABLE orders (
orderID INT PRIMARY KEY,
customerID INT NOT NULL,
orderDate DATETIME NOT NULL,
CONSTRAINT
ordersFkCustomers FOREIGN KEY (customerID)
REFERENCES customers (customerID)
)
INSERT INTO orders
VALUES (1, 999, '2017-08-03');
The response from the system
Error Code: 1452.
Cannot add or update a child row: a foreign key con-straint fails ('ex'.'orders', CONSTRAINT 'ordersFkCustomers' FOREIGN KEY ('customerID') REFERENCES 'customers' ('customerID'))