Question: Why do I have this error at the end? Everything seems to be typed right but it still gives me the foreign key constraint error?
Why do I have this error at the end? Everything seems to be typed right but it still gives me the foreign key constraint error?
mysql> create table vendor ( vname varchar(30) primary key, address varchar(100));
Query OK, 0 rows affected (0.29 sec)
mysql> mysql> create table department (
-> dname varchar(30) primary key,
-> phone char(10) not null);
Query OK, 0 rows affected (0.31 sec)
mysql> create table supply (
-> dname varchar(30),
-> vname varchar(30),
-> last_meeting_date date,
-> primary key (dname, vname),
-> foreign key (dname) references department(dname),
-> foreign key (vname) references vendor(vname));
ERROR 1215 (HY000): Cannot add foreign key constraint
Step by Step Solution
3.42 Rating (155 Votes )
There are 3 Steps involved in it
The error message youre encountering ERROR 1215 HY000 Cannot add foreign key constraint typically occurs when theres a mismatch between the data types ... View full answer
Get step-by-step solutions from verified subject matter experts
