

This error generally occurs because we have some values in the referencing field of the child table, which do not exist in the referenced/candidate field of the parent table. I've seen the other posts on this topic, but no luck.Īm I overseeing something or any idea what to do? Ordrelinje, CONSTRAINT Ordrelinje_fk FOREIGN KEY ( Ordre) REFERENCES Ordre ( OrdreID)) Cannot add or update a child row: a foreign key constraint fails ( srdjank. So when I try to insert values into ORDRELINJE table i get:Įrror Code: 1452.

ProduktBeskrivelse VARCHAR(100) DEFAULT NULL,ĬONSTRAINT Produkt_pk PRIMARY KEY (ProduktID)Īnd ORDRELINJE table: CREATE TABLE Ordrelinje (ĬONSTRAINT Ordrelinje_pk PRIMARY KEY (Ordre, Produkt),ĬONSTRAINT Ordrelinje_fk FOREIGN KEY (Ordre) REFERENCES Ordre (OrdreID),ĬONSTRAINT Ordrelinje_fk1 FOREIGN KEY (Produkt) REFERENCES Produkt (ProduktID) I have created tables in MySQL Workbench as shown below :ĬONSTRAINT Ordre_pk PRIMARY KEY (OrdreID),ĬONSTRAINT Ordre_fk FOREIGN KEY (KundeID) REFERENCES Kunde (KundeID)
