· 8 years ago · Aug 04, 2018, 03:56 PM
1Two or more foreign key in the table
2CREATE TABLE IF NOT EXISTS Seasons
3(
4 season_id INT NOT NULL AUTO_INCREMENT,
5 start_date DATE,
6 end_date DATE,
7 club_num INT,
8 desc TEXT,
9 PRIMARY KEY(season_id)
10);
11
12ALTER TABLE Seasons AUTO_INCREMENT=10000;
13
14
15
16CREATE TABLE IF NOT EXISTS Clubs
17(
18 club_id INT NOT NULL AUTO_INCREMENT,
19 club_name VARCHAR(70),
20 PRIMARY KEY(club_id)
21);
22
23ALTER TABLE Clubs AUTO_INCREMENT=100000;
24
25
26CREATE TABLE IF NOT EXISTS ClubsCloths
27(
28 season_id INT NOT NULL,
29 club_id INT NOT NULL,
30 first_shirt VARCHAR(50),
31 second_shirt VARCHAR(50),
32 PRIMARY KEY(season_id,club_id),
33 FOREIGN KEY (season_id) REFERENCES Seasons(season_id),
34 FOREIGN KEY (club_id) REFERENCES Clubs(club_id)
35);