ERROR 1452 (23000) at line 15: Cannot add or update a child row: a foreign key constraint fails (
cjcarey
.products
, CONSTRAINTproducts_ibfk_2
FOREIGN KEY (sName
) REFERENCESsuppliers
(suppliersname
))
-- Add products information
insert into Products values(1, 'Bike', 3, 200.00, 'Vehicle', 'Walmart', 180.00, 5, '2017-12-09');
insert into Product values(2, 'Couch', 12, 450.00, 'Household', 'Homegoods', 300.00, 3, '2018-05-14');
-- Add suppliers information
insert into Suppliers values('Walmart', '329 Carver Rd');
insert into Suppliers values('Homegoods', '4561 Parks Dr');
insert into Suppliers values('Hyvee', '2349 Morril St');
insert into Suppliers values('Lowes', '8828 WallyWorld Ave');
Suppliers table:
create table Suppliers(
SuppliersName varchar(255) not null,
address varchar(255),
primary key (SuppliersName)
);
Product table:
create table Products(
itemID int not null,
ProductName varchar(255),
RemainingQTY int,
Price float,
ProdType varchar(255) not null,
sName varchar(255) not null,
PurchasePrice float,
QTY int,
DateOfPurchase date,
primary key (itemID),
foreign key (ProdType) references ProductTypes(TypeName),
foreign key (sName) references Suppliers(SuppliersName)
);
I am not entirely sure what this error means? I think I referenced my foreign keys correctly..