I am not sure what is wrong with the following MySQL statements. I have created each table, but upon running the following statements I get the error:
Error Code: 1215. Cannot add foreign key constraint
MySQL statements:
/**
CREATE TABLE Episodes (
season INT,
num INT,
title VARCHAR(50),
director VARCHAR(50),
viewers DECIMAL(2, 1),
PRIMARY KEY (season, num)
);
CREATE TABLE Characters (
name VARCHAR(50),
house VARCHAR(50),
PRIMARY KEY (name)
);
**/
CREATE TABLE Appearances (
name VARCHAR(50),
season VARCHAR(50),
num INT,
PRIMARY KEY (name, season, num),
FOREIGN KEY (name) REFERENCES Characters(name),
FOREIGN KEY (season) REFERENCES Episodes(season)
);
What am I doing wrong here?