-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
73 lines (69 loc) · 2.56 KB
/
database.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
72
73
CREATE TABLE Users (
email VARCHAR(50) NOT NULL,
name VARCHAR(30) NOT NULL,
phonenumber VARCHAR(15) NOT NULL,
verify_email BOOLEAN NOT NULL,
admin BOOLEAN NOT NULL,
password VARCHAR(100),
createdAt TIMESTAMP NOT NULL,
updatedAt TIMESTAMP NOT NULL,
PRIMARY KEY (email)
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE Email_Token (
id INT NOT NULL AUTO_INCREMENT,
email VARCHAR(50) NOT NULL,
token VARCHAR(100) NOT NULL,
send_count INT NOT NULL,
createdAt TIMESTAMP NOT NULL,
updatedAt TIMESTAMP NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (email) REFERENCES Users (email) ON UPDATE CASCADE ON DELETE CASCADE
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE Library (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
location_road TEXT NOT NULL,
location_number TEXT NOT NULL,
location_detail TEXT NOT NULL,
manager_email VARCHAR(50) NOT NULL,
fac_beam_screen BOOLEAN NOT NULL,
fac_sound BOOLEAN NOT NULL,
fac_record BOOLEAN NOT NULL,
fac_placard BOOLEAN NOT NULL,
fac_self_promo BOOLEAN NOT NULL,
fac_need_volunteer BOOLEAN NOT NULL,
latitude FLOAT NOT NULL,
longitude FLOAT NOT NULL,
admin_approved ENUM('0','1','2','3') NOT NULL,
createdAt TIMESTAMP NOT NULL,
updatedAt TIMESTAMP NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (manager_email) REFERENCES Users (email) ON UPDATE CASCADE ON DELETE CASCADE
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE Session (
id INT NOT NULL AUTO_INCREMENT,
library_id INT,
user_email VARCHAR(50) NOT NULL,
session_name VARCHAR(50) NOT NULL,
session_time VARCHAR(10) NOT NULL,
introduce TEXT,
document VARCHAR(50),
admin_approved ENUM('0','1','2','3') NOT NULL,
createdAt TIMESTAMP NOT NULL,
updatedAt TIMESTAMP NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (library_id) REFERENCES Library (id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (user_email) REFERENCES Users (email) ON UPDATE CASCADE ON DELETE CASCADE
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE Volunteer (
id INT NOT NULL AUTO_INCREMENT,
library_id INT NOT NULL,
user_email VARCHAR(50) NOT NULL,
introduce TEXT,
admin_approved ENUM('0','1','2','3') NOT NULL,
createdAt TIMESTAMP NOT NULL,
updatedAt TIMESTAMP NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (library_id) REFERENCES Library (id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (user_email) REFERENCES Users (email) ON UPDATE CASCADE ON DELETE CASCADE
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;