-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddl.sql
29 lines (27 loc) · 877 Bytes
/
ddl.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
CREATE TABLE tbl_user (
id VARCHAR(255) NOT NULL,
number CHAR(4) NOT NULL,
name VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC) VISIBLE,
UNIQUE INDEX number_UNIQUE (number ASC) VISIBLE
);
CREATE TABLE tbl_reservation (
id INT NOT NULL AUTO_INCREMENT,
user_id VARCHAR(255) NOT NULL,
room CHAR(3) NOT NULL,
time CHAR(6) NOT NULL,
description VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(user_id) REFERENCES tbl_user(id) ON DELETE CASCADE,
UNIQUE INDEX id_UNIQUE (id ASC) VISIBLE
);
CREATE TABLE tbl_member (
id INT NOT NULL AUTO_INCREMENT,
reservation_id INT NOT NULL,
user_id VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(user_id) REFERENCES tbl_user(id) ON DELETE CASCADE,
FOREIGN KEY(reservation_id) REFERENCES tbl_reservation(id) ON DELETE CASCADE,
UNIQUE INDEX id_UNIQUE (id ASC) VISIBLE
);