forked from zvmsbackend/zvms3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zvms.sql
91 lines (80 loc) · 2.18 KB
/
zvms.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
CREATE TABLE IF NOT EXISTS user(
userid INT PRIMARY KEY,
username VARCHAR(5) UNIQUE,
password CHAR(32),
permission SMALLINT,
classid INT,
FOREIGN KEY (classid) REFERENCES class(id)
);
CREATE TABLE IF NOT EXISTS class(
id INT PRIMARY KEY,
name VARCHAR(5)
);
CREATE TABLE IF NOT EXISTS volunteer(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description TEXT,
status SMALLINT,
holder INT,
type SMALLINT,
reward INT,
time DATE,
FOREIGN KEY (holder) REFERENCES user(userid)
);
CREATE TABLE IF NOT EXISTS user_vol(
userid INT,
volid INT,
status SMALLINT,
thought TEXT,
reward INT,
PRIMARY KEY(userid, volid),
FOREIGN KEY (userid) REFERENCES user(userid),
FOREIGN KEY (volid) REFERENCES volunteer(id)
);
CREATE TABLE IF NOT EXISTS class_vol(
classid INT,
volid INT,
max INT,
PRIMARY KEY (classid, volid),
FOREIGN KEY (classid) REFERENCES class(id),
FOREIGN KEY (volid) REFERENCES volunteers(id)
);
CREATE TABLE IF NOT EXISTS picture(
userid INT,
volid INT,
filename VARCHAR(36),
FOREIGN KEY (userid) REFERENCES users(userid),
FOREIGN KEY (volid) REFERENCES volunteer(id)
);
CREATE TABLE IF NOT EXISTS issue(
id INTEGER PRIMARY KEY AUTOINCREMENT,
author INT,
content VARCHAR(64),
time DATETIME,
FOREIGN KEY (author) REFERENCES user(userid)
);
CREATE TABLE IF NOT EXISTS notice(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(32),
content TEXT,
sender INT,
school BOOLEAN,
expire DATETIME,
FOREIGN KEY (sender) REFERENCES user(userid)
);
CREATE TABLE IF NOT EXISTS user_notice(
userid INT,
noticeid INT,
PRIMARY KEY (userid, noticeid),
FOREIGN KEY (userid) REFERENCES user(userid),
FOREIGN KEY (noticeid) REFERENCES notice(id)
);
CREATE TABLE IF NOT EXISTS class_notice(
classid INT,
noticeid INT,
PRIMARY KEY (classid, noticeid),
FOREIGN KEY (classid) REFERENCES class(id),
FOREIGN KEY (noticeid) REFERENCES notice(id)
);
INSERT INTO class(id, name) VALUES(0, '义管会');
INSERT INTO user(userid, username, password, permission, classid) VALUES(0, '系统', '', 0, 0);