I have two tables movies and cinema. In the cinema table, there is a primary key called cinema_id. I am trying to make this primary key from the cinema table a foreign key in the movies table. So I used
alter table movies
add foreign key(cinema_id)
references cinema(cinema_id)
but I get an error message that says:
#1072 - Key column 'cinema_id' doesn't exist in table
so I added a column and then tried to create a foreign key again and there was an error message that said :
#1452 - Cannot add or update a child row: a foreign key constraint fails
I have already checked the column type and it is the same. Can someone please help me with this? I have no idea what to do.