I am trying to create a series of tables for a hospital database, and whenever i try to run the code, i get an error saying "Error Code 1215: Cannot add foreign key constraint." I've done a lot of research to see what i've done wrong, but i cant figure it out. What's wrong with my foreign keys? Here are the relevant tables. Thanks.
create table Patient(
num int(8),
Fname varchar(20),
Lname varchar(20),
SSN char(11),
dateofBirth date,
primary key(num)
);
create table Department(
Description varchar(250),
DepCode char(3),
DepName varchar(15),
Supervisor int(8),
building char(6),
primary key(DepCode),
constraint fk_supervisor foreign key(Supervisor) references Employee(ID)
);
create table Employee(
ID int(8),
Fname varchar(20),
Lname varchar(20),
SSN char(11),
Specialty varchar(15),
dateofHire date,
primary key(ID)
);