I was dumb and created a year ago tables for a customer. Now I know better and should have used relations. Now I am trying to create them in Navicat. Executing:
ALTER TABLE geerdink_new.dossier
ADD CONSTRAINT fk_dossier_klant_1
FOREIGN KEY (dossierKlantID)
REFERENCES geerdink_new.klant (klantID)
I am getting some errors:
[Msg] Failed – Error on Foreign Key fk_dossier_klant_1 – 1452 – Cannot add or update a child row: a foreign key constraint fails (
geerdink_new.#sql-420_51, CONSTRAINTfk_dossier_klant_1FOREIGN KEY (dossierKlantID) REFERENCESklant(klantID))
How am I able to solve this?
This is not a Navicat error, but a MySQL error. Something is not matching properly when you’re trying to create your constraint, likely:
1) The column definitions are not identical (for instance one is an unsigned integer, and the other is a signed integer)
2) There are values in one column that do not correspond with values in the column you’re creating a relationship with.
edit: Try this query: