Hi
I'm trying to make 2 tables and I have to use foreign keys
this is the code I wrote but it doesn't work and I don't uderstand what's wrong with those foreign keys
the given error is:
Error | 1005 | Can't create table '.\cddb\artist.frm' (errno: 150)
this is the code
CREATE TABLE Artist
(artistid INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
name CHAR (255) NOT NULL,
index (artistid, name),
FOREIGN KEY (artistid, name) REFERENCES CD(artist,name), # ON UPDATE CASCADE,
countryid CHAR (3) NOT NULL,
website CHAR (255),
description TEXT,
PRIMARY KEY (artistid)) ENGINE=INNODB;
show warnings;
INSERT INTO Artist(artistid,name,countryid,website,description) VALUES (NULL, 'The Chemical Brothers', 'UK', '
http://www.thechemicalbrothers.com';, 'blablablablablabla');
INSERT INTO Artist(artistid,name,countryid,website,description) VALUES (NULL, 'Moby', 'USA', '
http://www.moby.com';, 'blabla');
INSERT INTO Artist(artistid,name,countryid,website,description) VALUES (NULL, 'Skin', 'UK', '
http://www.skinmusic.net';, 'blablabla');
show warnings;
CREATE TABLE CD (
cdid int(10) UNSIGNED AUTO_INCREMENT NOT NULL,
artist int(10) UNSIGNED NOT NULL,
name CHAR (255) NOT NULL,
index (artist,name),
FOREIGN KEY (artist, name) REFERENCES Artist(artistid, name),
title char(255) NOT NULL,
label char(255) NOT NULL,
released date NOT NULL,
PRIMARY KEY (cdid)) ENGINE=INNODB;
INSERT INTO CD (artist,name,title,label,released) VALUES (NULL, 'The Chemical Brothers', 'Push the button', 'EMI', '2005-01-24');
thanks a lot for your attenction