SQLFiddle を使用してこれらのデータベース テーブルを作成していますが、問題が見られないエラーが発生しています。Club
一番下の主キー(
が間違っていることを教えてくれることに関係しています。このスクリプトの何が問題で、その理由は何ですか?
CREATE TABLE Club
(
CLUB_ID int NOT NULL,
CLUB_NAME varchar(255) NOT NULL,
STREET_ADDRESS varchar(255) NOT NULL,
CITY varchar(255) NOT NULL,
STATE varchar(2) NOT NULL,
ZIPCODE int NOT NULL,
PHONE int NOT NULL,
PRIMARY KEY(CLUB_ID)
);
CREATE TABLE Member
(
MEMBER_ID int NOT NULL,
FIRST_NAME varchar(255) NOT NULL,
LAST_NAME varchar(255) NOT NULL,
STREET_ADDRESS varchar(255) NOT NULL,
CITY varchar(255) NOT NULL,
STATE varchar(2) NOT NULL,
ZIPCODE int NOT NULL,
PRIMARY KEY(MEMBER_ID)
);
CREATE TABLE Phone
(
PHONE_ID int NOT NULL,
MEMBER_ID int,
PHONE_TYPE varchar(255) NOT NULL,
PHONE_NUMBER int NOT NULL,
PRIMARY KEY(PHONE_ID),
FOREIGN KEY(MEMBER_ID) REFERENCES Member(MEMBER_ID)
);
CREATE TABLE Membership
(
MEMBERSHIP_ID int NOT NULL,
MEMBER_ID int,
CLUB_ID int,
JOIN_DATE varchar(255) NOT NULL,
END_DATE varchar(255),
REASON varchar(255),
PRIMARY KEY(MEMBERSHIP_ID),
FOREIGN KEY(MEMBER_ID) REFERENCES Member(MEMBER_ID),
FOREIGN KEY(CLUB_ID) REFERENCES Club(CLUB_ID)
);
CREATE TABLE Talent
(
TALENT_ID int NOT NULL,
TALENT_NAME varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY(TALENT_ID)
);
CREATE TABLE Member_Talent
(
MEMBER_ID int,
TALENT_ID int,
PRIMARY KEY(MEMBER_ID, TALENT_ID),
FOREIGN KEY(MEMBER_ID) REFERENCES Member(MEMBER_ID),
FOREIGN KEY(TALENT_ID) REFERENCES Talent(TALENT_ID)
);
CREATE TABLE Award
(
AWARD_ID int NOT NULL,
AWARD_NAME varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY(AWARD_ID)
);
CREATE TABLE Member_Award
(
MEMBER_AWARD_ID int NOT NULL,
MEMBER_ID int,
AWARD_ID int,
AWARD_DATE varchar(255) NOT NULL,
PRIMARY KEY(MEMBER_AWARD_ID),
FOREIGN KEY(MEMBER_ID) REFERENCES Member(MEMBER_ID),
FOREIGN KEY(AWARD_ID) REFERENCES Award(AWARD_ID),
);
CREATE TABLE Office
(
OFFICE_ID int NOT NULL,
CLUB_ID int,
OFFICE_NAME varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY(OFFICE_ID),
FOREIGN KEY(CLUB_ID) REFERENCES Club(CLUB_ID)
);
CREATE TABLE Officer
(
OFFICER_ID int NOT NULL,
OFFICE_ID int,
MEMBER_ID int,
YEAR int NOT NULL,
PRIMARY KEY(OFFICER_ID),
FOREIGN KEY(OFFICE_ID) REFERENCES Office(OFFICE_ID),
FOREIGN KEY(MEMBER_ID) REFERENCES Member(MEMBER_ID)
);
CREATE TABLE Project
(
PROJECT_ID int NOT NULL,
CLUB_ID int,
PROJECT_NAME varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PROJECT_DATE varchar(255) NOT NULL,
PROJECT_TYPE varchar(255) NOT NULL,
COST int NOT NULL,
REVENUE int NOT NULL,
PRIMARY KEY(PROJECT_ID),
FOREIGN KEY(CLUB_ID) REFERENCES Club(CLUB_ID)
);
CREATE TABLE Member_Project
(
MEMBER_ID int,
PROJECT_ID int,
PRIMARY KEY(MEMBER_ID, PROJECT_ID),
FOREIGN KEY(MEMBER_ID) REFERENCES Member(MEMBER_ID),
FOREIGN KEY(PROJECT_ID) REFERENCES Project(PROJECT_ID)
);