This repository has been archived by the owner on Apr 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
teajudge.sql
222 lines (182 loc) · 8.9 KB
/
teajudge.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
CREATE DATABASE IF NOT EXISTS `teajudge` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE `teajudge`;
CREATE TABLE IF NOT EXISTS `course` (
`cid` int(11) NOT NULL,
`cname` varchar(256) COLLATE utf8_bin NOT NULL,
`author` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `folder` (
`fid` int(11) NOT NULL,
`cid` int(11) NOT NULL,
`fname` varchar(128) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `group` (
`gid` int(11) NOT NULL,
`gname` varchar(128) COLLATE utf8_bin NOT NULL,
`canCreateUser` tinyint(2) NOT NULL DEFAULT '0',
`canCreateTask` tinyint(2) NOT NULL DEFAULT '0',
`canGrant` tinyint(2) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT IGNORE INTO `group` (`gid`, `gname`, `canCreateUser`, `canCreateTask`, `canGrant`) VALUES
(1, 'admin', 1, 1, 1),
(2, 'teacher', 0, 1, 0);
CREATE TABLE IF NOT EXISTS `lang` (
`lid` int(11) NOT NULL,
`lcode` varchar(10) COLLATE utf8_bin NOT NULL,
`lname` varchar(25) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT IGNORE INTO `lang` (`lid`, `lcode`, `lname`) VALUES
(1, 'c_cpp', 'C/C++'),
(2, 'python', 'Python');
CREATE TABLE IF NOT EXISTS `task` (
`tid` int(11) NOT NULL,
`cid` int(11) NOT NULL,
`fid` int(11) DEFAULT NULL,
`tname` varchar(128) COLLATE utf8_bin NOT NULL,
`torder` tinyint(3) unsigned NOT NULL DEFAULT '0',
`type` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `user` (
`uid` int(11) NOT NULL,
`login` varchar(64) COLLATE utf8_bin NOT NULL,
`password` varchar(130) COLLATE utf8_bin NOT NULL,
`email` varchar(256) COLLATE utf8_bin DEFAULT NULL,
`firstname` varchar(64) COLLATE utf8_bin NOT NULL,
`lastname` varchar(64) COLLATE utf8_bin NOT NULL,
`canCreateUser` tinyint(2) NOT NULL DEFAULT '0',
`canCreateTask` tinyint(2) NOT NULL DEFAULT '0',
`canGrant` tinyint(2) NOT NULL DEFAULT '0',
`restoreToken` varchar(128) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT IGNORE INTO `user` (`uid`, `login`, `password`, `email`, `firstname`, `lastname`, `canCreateUser`, `canCreateTask`, `canGrant`, `restoreToken`) VALUES
(1, 'admin', 'c3284d0f94606de1fd2af172aba15bf3', NULL, '', 'Administrator', 0, 0, 0, NULL);
CREATE TABLE IF NOT EXISTS `user_course` (
`uid` int(11) DEFAULT NULL,
`gid` int(11) DEFAULT NULL,
`cid` int(11) NOT NULL,
`fid` int(11) DEFAULT NULL,
`startTime` int(10) unsigned NOT NULL,
`endTime` int(10) unsigned NOT NULL,
`clearTime` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `user_group` (
`uid` int(11) NOT NULL,
`gid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT IGNORE INTO `user_group` (`uid`, `gid`) VALUES
(1, 1);
CREATE TABLE IF NOT EXISTS `user_task` (
`utid` int(11) NOT NULL,
`uid` int(11) NOT NULL,
`tid` int(11) NOT NULL,
`vid` int(11) NOT NULL,
`passed` tinyint(3) unsigned NOT NULL,
`time` varchar(600) COLLATE utf8_bin NOT NULL,
`memory` varchar(600) COLLATE utf8_bin NOT NULL,
`status` varchar(400) COLLATE utf8_bin NOT NULL,
`lid` int(11) NOT NULL,
`ranges` varchar(512) COLLATE utf8_bin NOT NULL,
`submissionCode` text COLLATE utf8_bin NOT NULL,
`history` mediumtext COLLATE utf8_bin NOT NULL,
`startDate` int(10) unsigned NOT NULL,
`submissionDate` int(10) unsigned NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `variant` (
`vid` int(11) NOT NULL,
`tid` int(11) NOT NULL,
`statement` text COLLATE utf8_bin NOT NULL,
`testCount` tinyint(3) unsigned NOT NULL,
`testNames` text COLLATE utf8_bin NOT NULL,
`testData` text COLLATE utf8_bin NOT NULL,
`testAnswer` text COLLATE utf8_bin NOT NULL,
`publicity` varchar(528) COLLATE utf8_bin NOT NULL,
`timeLimit` smallint(5) unsigned NOT NULL,
`memoryLimit` tinyint(3) unsigned NOT NULL,
`help` varchar(300) COLLATE utf8_bin NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `variant_lang` (
`vlid` int(11) NOT NULL,
`tid` int(11) NOT NULL,
`vid` int(11) NOT NULL,
`lid` int(11) NOT NULL,
`pattern` text COLLATE utf8_bin NOT NULL,
`ranges` varchar(512) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ALTER TABLE `course`
ADD PRIMARY KEY (`cid`), ADD KEY `author` (`author`);
ALTER TABLE `folder`
ADD PRIMARY KEY (`fid`), ADD KEY `cid` (`cid`);
ALTER TABLE `group`
ADD PRIMARY KEY (`gid`);
ALTER TABLE `lang`
ADD PRIMARY KEY (`lid`);
ALTER TABLE `task`
ADD PRIMARY KEY (`tid`), ADD KEY `cid` (`cid`), ADD KEY `fid` (`fid`);
ALTER TABLE `user`
ADD PRIMARY KEY (`uid`), ADD UNIQUE KEY `login` (`login`);
ALTER TABLE `user_course`
ADD KEY `cid` (`cid`), ADD KEY `fid` (`fid`), ADD KEY `uid` (`uid`), ADD KEY `gid` (`gid`);
ALTER TABLE `user_group`
ADD KEY `uid` (`uid`), ADD KEY `gid` (`gid`);
ALTER TABLE `user_task`
ADD PRIMARY KEY (`utid`), ADD KEY `uid` (`uid`), ADD KEY `tid` (`tid`), ADD KEY `vid` (`vid`), ADD KEY `lid` (`lid`);
ALTER TABLE `variant`
ADD PRIMARY KEY (`vid`), ADD KEY `tid` (`tid`);
ALTER TABLE `variant_lang`
ADD PRIMARY KEY (`vlid`), ADD KEY `vid` (`vid`), ADD KEY `lid` (`lid`), ADD KEY `tid` (`tid`);
ALTER TABLE `course`
MODIFY `cid` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `folder`
MODIFY `fid` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `group`
MODIFY `gid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
ALTER TABLE `lang`
MODIFY `lid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
ALTER TABLE `task`
MODIFY `tid` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `user`
MODIFY `uid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
ALTER TABLE `user_task`
MODIFY `utid` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `variant`
MODIFY `vid` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `variant_lang`
MODIFY `vlid` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `course`
ADD CONSTRAINT `course_ibfk_1` FOREIGN KEY (`author`) REFERENCES `user` (`uid`) ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE `folder`
ADD CONSTRAINT `folder_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `course` (`cid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `task`
ADD CONSTRAINT `task_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `course` (`cid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `task_ibfk_2` FOREIGN KEY (`fid`) REFERENCES `folder` (`fid`) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE `user_course`
ADD CONSTRAINT `user_course_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_course_ibfk_2` FOREIGN KEY (`cid`) REFERENCES `course` (`cid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_course_ibfk_3` FOREIGN KEY (`fid`) REFERENCES `folder` (`fid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_course_ibfk_4` FOREIGN KEY (`gid`) REFERENCES `group` (`gid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `user_group`
ADD CONSTRAINT `user_group_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_group_ibfk_2` FOREIGN KEY (`gid`) REFERENCES `group` (`gid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `user_task`
ADD CONSTRAINT `user_task_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_task_ibfk_2` FOREIGN KEY (`tid`) REFERENCES `task` (`tid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_task_ibfk_3` FOREIGN KEY (`vid`) REFERENCES `variant` (`vid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_task_ibfk_4` FOREIGN KEY (`lid`) REFERENCES `lang` (`lid`) ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE `variant`
ADD CONSTRAINT `variant_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `task` (`tid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `variant_lang`
ADD CONSTRAINT `variant_lang_ibfk_3` FOREIGN KEY (`tid`) REFERENCES `task` (`tid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `variant_lang_ibfk_1` FOREIGN KEY (`vid`) REFERENCES `variant` (`vid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `variant_lang_ibfk_2` FOREIGN KEY (`lid`) REFERENCES `lang` (`lid`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;