-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreat all table.sql
66 lines (60 loc) · 1.63 KB
/
creat all 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
CREATE TABLE Visitor
(
Visitor_id INT NOT NULL,
Visitor_phone VARCHAR(15) NOT NULL,
Visitor_type VARCHAR(15) NOT NULL,
Visitor_name VARCHAR(35) NOT NULL,
Visitor_email VARCHAR(40) NOT NULL,
PRIMARY KEY (Visitor_id)
);
CREATE TABLE Event
(
Event_size VARCHAR(10) NOT NULL,
Event_public VARCHAR(10) NOT NULL,
Event_price FLOAT NOT NULL,
Event_id INT NOT NULL,
PRIMARY KEY (Event_id)
);
CREATE TABLE Facilities
(
Facilities_id INT NOT NULL,
Facilities_age INT,
Facilities_height FLOAT,
Facilities_location VARCHAR(10) NOT NULL,
Employee_id INT NOT NULL,
PRIMARY KEY (Facilities_id)
);
CREATE TABLE Facilities_mode
(
F_mode CHAR(10) NOT NULL,
PRIMARY KEY (F_mode)
);
CREATE TABLE My_Order
(
Order_date DATE NOT NULL,
Visitor_id INT NOT NULL,
Event_id INT NOT NULL,
PRIMARY KEY (Visitor_id, Event_id),
FOREIGN KEY (Visitor_id) REFERENCES Visitor(Visitor_id),
FOREIGN KEY (Event_id) REFERENCES Event(Event_id)
);
CREATE TABLE Play
(
Play_time VARCHAR(5) NOT NULL,
Play_date DATE NOT NULL,
Visitor_id INT NOT NULL,
Facilities_id INT NOT NULL,
PRIMARY KEY (Play_time, Play_date, Visitor_id, Facilities_id),
FOREIGN KEY (Visitor_id) REFERENCES Visitor(Visitor_id),
FOREIGN KEY (Facilities_id) REFERENCES Facilities(Facilities_id)
);
CREATE TABLE mode_of
(
Date_mode DATE NOT NULL,
F_mode CHAR(10) NOT NULL,
Facilities_id INT NOT NULL,
PRIMARY KEY (Date_mode,F_mode, Facilities_id),
FOREIGN KEY (F_mode) REFERENCES Facilities_mode(F_mode),
FOREIGN KEY (Facilities_id) REFERENCES Facilities(Facilities_id)
);
select * from my_order