This is what I have written:
create table employee (
emp_id int,
emp_first_name varchar(20),
emp_last_name varchar(20),
dept_id int,
email varchar(255),
primary key(emp_id, dept_id)
);
create table department(
dept_id int primary key,
dept_name varchar(255),
gm_no int,
foreign key(dept_id) references employee(dept_id)
);
but when I try to create the department table, it gives me the error(ERROR 1215 (HY000): Cannot add foreign key constraint)
all help is appreciated. thank you.