-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabaseProject.sql
56 lines (41 loc) · 1.11 KB
/
DatabaseProject.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
CREATE DATABASE Tiproject;
USE Tiproject;
CREATE TABLE Players(
PlayerID VARCHAR(20),
PlayName VARCHAR(20),
TeamName VARCHAR(15),
Country VARCHAR(10),
Position VARCHAR(10),
DateOfBirth DATE,
PRIMARY KEY (PlayerId));
CREATE TABLE Teams(
TeamName VARCHAR(15),
Country VARCHAR(10),
StartDate DATE,
League VARCHAR(10),
PRIMARY KEY (TeamName));
CREATE TABLE Games (
GameID INT(20),
WinTeam VARCHAR(15),
LossTeam VARCHAR(15),
WhichGroup VARCHAR(10),
TiEvent VARCHAR(17),
PRIMARY KEY (GameID));
CREATE TABLE Ti (
TiEvent Varchar(20),
TiYear Date,
Country VARCHAR(10),
PRIMARY KEY (TiEvent));
CREATE TABLE GameAttend (
GameID INT(20),
PlayerID VARCHAR(20),
PRIMARY KEY (GameID, PlayerID));
ALTER TABlE Players
ADD FOREIGN KEY (TeamName)
REFERENCES Teams(TeamName);
AlTER TABLE Games
ADD FOREIGN KEY (TiEvent) REFERENCES Ti (TiEvent);
ALTER TABLE GameAttend
ADD FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID);
ALTER TABLE GameAttend
ADD FOREIGN KEY (GameID) REFERENCES Games (GameID);