I am getting this error when trying to add any data in the myphpadmin.
#1452 - Cannot add or update a child row: a foreign key constraint fails (`artdb/image`, CONSTRAINT `image_ibfk_1` FOREIGN KEY (`artid`) REFERENCES `artist` (`artid`))
I am using only one field to input so I know that I am using a valid artid.
After playing with around it seems as though I can only enter 1 artid and the rest gets kicked out, but that is only if I go directly thru the Insert on myphpadmin. If I re-add the tables and go with a different artid it works only for that one.
Here are the 2 tables I am working with -
Code:
CREATE TABLE artist (artid varchar(11) NOT NULL PRIMARY KEY,
fullName tinytext Not Null,
firstName tinytext NULL,
middleName tinytext NULL,
lastName tinytext NULL,
otherName tinytext NULL,
called tinytext NULL,
dob_xt tinytext NULL,
dob tinytext NULL,
dod_xt tinytext NULL,
dod tinytext,
nationality tinytext,
artform tinytext,
movid_1 varchar(7),
movid_2 varchar(7),
movid_3 varchar(7),
medid_1 varchar(7),
medid_2 varchar(7),
medid_3 varchar(7),
genid_1 varchar(7),
genid_2 varchar(7),
genid_3 varchar(7),
perid varchar(7),
bio mediumtext,
keywords tinytext,
notes text,
verified BOOL);
CREATE TABLE image (imgid varchar(11) NOT NULL PRIMARY KEY,
artid varchar(11) NOT NUll,
title tinytext,
datext_1 tinytext,
date tinytext,
medid varchar(7),
size_inch tinytext,
size_cm tinytext,
musid varchar(7),
movid varchar(7),
genid varchar(7),
perid varchar(7),
bio text,
keywords text,
notes text,
verified BOOL,
FOREIGN KEY (artid) REFERENCES artist (artid)
);
I understand a bit of the error msg but not this part -
`image_ibfk_1`
I am not really sure that I need to use a Foreign Key. But I can't get a query to work and was thinking this may be the problem.