-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.sql
71 lines (65 loc) · 1.63 KB
/
table.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
CREATE TABLE playo.player
(
pname varchar(40),
email varchar(40) PRIMARY KEY,
region varchar(10),
gender varchar(6),
city varchar(12),
password varchar(30),
dob date
);
CREATE TABLE playo.owner
(
oname varchar(40),
mobile varchar(14) PRIMARY KEY,
password varchar(30),
dob date,
gender varchar(6)
);
CREATE TABLE playo.sports
(
sname varchar(20),
sid int NOT NULL AUTO_INCREMENT PRIMARY KEY
);
CREATE TABLE playo.arena
(
aid int NOT NULL AUTO_INCREMENT PRIMARY KEY,
opening time,
closing time,
aname varchar(20),
rating real,
city varchar(12),
region varchar(10),
sid int,
mobile varchar(14),
FOREIGN KEY(sid) REFERENCES playo.sports(sid) ON UPDATE CASCADE ON DELETE SET NULL,
FOREIGN KEY(mobile) REFERENCES playo.owner(mobile) ON UPDATE CASCADE ON DELETE SET NULL
);
CREATE TABLE playo.court
(
cid int NOT NULL AUTO_INCREMENT PRIMARY KEY,
cost int,
aid int,
FOREIGN KEY(aid) REFERENCES playo.arena(aid) ON UPDATE CASCADE ON DELETE SET NULL
);
CREATE TABLE playo.booking
(
bid int NOT NULL AUTO_INCREMENT PRIMARY KEY,
start_slot int,
end_slot int,
bdate date,
hosting bool,
email varchar(40),
cid int,
FOREIGN KEY(email) REFERENCES playo.player(email) ON UPDATE CASCADE ON DELETE SET NULL,
FOREIGN KEY(cid) REFERENCES playo.court(cid) ON UPDATE CASCADE ON DELETE SET NULL
);
CREATE TABLE playo.hosting
(
bid int,
email varchar(40),
max_players int,
PRIMARY KEY(bid,email),
FOREIGN KEY(bid) REFERENCES playo.booking(bid) ON UPDATE CASCADE,
FOREIGN KEY(email) REFERENCES playo.player(email) ON UPDATE CASCADE
);