I have this MySQL code:
drop table artist;
drop table CDs;
drop table label;
drop table guests;
drop table genre;
drop table country;
drop table short_CD_info;
drop table short_guest_info;
create table artist(pseudo_of_artist varchar(50),name varchar(50), surname varchar(50), CDs varchar(50), date_of_birthday year, genre varchar(50), country varchar(50));
create table CDs(title varchar(100), pseudo_of_artist varchar(50), label varchar(50), tracks int(50), pseudo_of_guests varchar(50), genre varchar(50), edition enum('Digipack','Plastic','Other'),year_of_cutting year,iTunes_bonus enum('Yes', 'No'));
create table label(name_of_label varchar(50), country varchar(50), owner varchar(50), year_of_founding year);
create table guests(pseudo_of_guests varchar(50), name varchar(50), surname varchar(50), date_of_birthday year, CDs varchar(100), country varchar(50));
create table genre(name_of_genre varchar(50), country varchar(50), example_of_artist varchar(50));
create table country(code varchar(10), full_name varchar(50));
create table short_CD_info(pseudo_of_artist varchar(50), title varchar(100));
create table short_guest_info(pseudo_of_guests varchar(50), title varchar(100));
ALTER TABLE artist
ADD CONSTRAINT pk_artistID PRIMARY KEY(pseudo_of_artist);
alter table CDs
add constraint pk_CDsID primary key(title);
alter table label
add constraint pk_labelID primary key(name_of_label);
alter table guests
add constraint pk_guestsID primary key(pseudo_of_guests);
alter table genre
add constraint pk_genreID primary key(name_of_genre);
alter table country
add constraint pk_countryID primary key(code);
alter table short_CD_info
add constraint pk_scdiID primary key(pseudo_of_artist, title);
alter table short_guest_info
add constraint pk_sgiID primary key(pseudo_of_guests, title);
ALTER TABLE artist
ADD CONSTRAINT artits1_fk
FOREIGN KEY (CDs)
REFERENCES short_CD_info(title);
ALTER TABLE artist
ADD CONSTRAINT fk_artist2
FOREIGN KEY (genre)
REFERENCES genre(name_of_genre);
ALTER TABLE artist
ADD CONSTRAINT fk_artist3
FOREIGN KEY (country)
REFERENCES country(code);
ALTER TABLE CDs
ADD CONSTRAINT fk_CDs1
FOREIGN KEY (pseudo_of_artist)
REFERENCES short_CD_info(pseudo_of_artist);
ALTER TABLE CDs
ADD CONSTRAINT fk_CD2
FOREIGN KEY (label)
REFERENCES label(name_of_label);
ALTER TABLE CDs
ADD CONSTRAINT fk_CD3
FOREIGN KEY (pseudo_of_guests)
REFERENCES short_guest_info(pseudo_of_guests);
ALTER TABLE CDs
ADD CONSTRAINT fk_CD4
FOREIGN KEY (genre)
REFERENCES genre(name_of_genre);
ALTER TABLE label
ADD CONSTRAINT fk_label1
FOREIGN KEY (country)
REFERENCES country(code);
ALTER TABLE guests
ADD CONSTRAINT fk_guests1
FOREIGN KEY (CDs)
REFERENCES short_guest_info(title);
ALTER TABLE guests
ADD CONSTRAINT fk_guests2
FOREIGN KEY (country)
REFERENCES country(code);
ALTER TABLE genre
ADD CONSTRAINT fk_genre1
FOREIGN KEY (country)
REFERENCES country(code);
ALTER TABLE genre
ADD CONSTRAINT fk_genre2
FOREIGN KEY (example_of_artist)
REFERENCES artist(pseudo_of_artist);
And I don't know why it doesn't work. I read about the same problem in this forum, but I still got no solution. The primary key is ok, but workbench quittin' with foreign key addition.
Could anyone help? :)