I am continuously getting this flag:
1452 - Cannot add or update a child row: a foreign key constraint fails (
mydb4653
.stars
, CONSTRAINTfk_stars_movie
FOREIGN KEY (movieID
) REFERENCESmovie
(id
))
when I try to insert the data into the table
These are the tables
movie(id, title, relYear, category, runTime, director,
studioName, description, rating)
actor(aID, fName, surname, gender)
stars(movieID, actorID)
movGenre(movieID, genre)
I think it could have something to do with the fact that its not the only movieID as it is the only one I am having issues with. It is definitely indexed
I have tried:
CREATE TABLE stars
(movieID INTEGER,
actorID INTEGER NOT NULL PRIMARY KEY,
CONSTRAINT fk_stars_movie FOREIGN KEY (movieID) REFERENCES movie(ID)
);
as well as manually making it the foreign key in the relation view. It is also the same data type as its primary key so that's not the issue either.
CREATE TABLE movie
(id INTEGER NOT NULL PRIMARY KEY,
title VARCHAR(100),
relYear INTEGER,
category VARCHAR(5),
runTime INTEGER,
director VARCHAR(50),
studioName VARCHAR(100),
description VARCHAR(500),
rating DECIMAL(10,2)
);