I have 3 table: CD
, Song
and Song_Details
which is a relationship between CD
& Song
:
create table Song(
ID int not null auto_increment,
Title varchar(255) not null,
Length float not null,
primary key (ID, Title)
);
create table CD(
Title varchar(255) not null,
CD_Number int not null,
primary key (Title, CD_Number)
);
Create table Song_Details(
CD_Title varchar(255) not null,
Song_Title varchar(255) not null,
Track_Number int not null,
primary key(CD_Title, Song_Title),
foreign key(CD_Title) references CD(Title),
foreign key(Song_Title) references Song(Title)
);
I have managed to find out that this line in Song_Details
:
foreign key(Song_Title) references Song(Title)
is throwing the Error 1215(HY000): Cannot add foreign key constraint;
Could anyone help me see based on my table, what could be causing this issue?