CREATE TABLE Artist
(
A_id INT NOT NULL,
A_song varchar(100),
A_name varchar(100),
PRIMARY KEY(A_id,A_song)
);
CREATE TABLE Instrument
(
I_id int NOT NULL,
I_keys varchar(100),
I_name varchar(100),
PRIMARY KEY(I_id,I_name),
a_id int NOT NULL,
FOREIGN KEY (a_id) references Artist(A_id)
);
CREATE TABLE Song
(
S_id int NOT NULL PRIMARY KEY,
S_vocalist varchar(100),
S_nom int NOT NULL,
S_name varchar(100),
FOREIGN KEY (S_name) references Artist(A_song),
S_inst varchar(100),
FOREIGN KEY (S_inst) references Instrument(I_name),
a_id int NOT NULL,
FOREIGN KEY (a_id) references Artist(A_id)
);
I am getting this error: "ERROR 1215 (HY000): Cannot add foreign key constraint" probably on this part of the code :
S_inst varchar(100),
FOREIGN KEY (S_inst) references Instrument(I_name),
Please solve.