-
Notifications
You must be signed in to change notification settings - Fork 0
/
yoke.sql
491 lines (406 loc) · 17.8 KB
/
yoke.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2019/9/1 15:48:35 */
/*==============================================================*/
drop table if exists admins;
drop table if exists answer;
drop table if exists answer_praise;
drop table if exists answer_report;
drop table if exists class_segments;
drop table if exists course;
drop table if exists course_class;
drop table if exists course_comment;
drop table if exists course_comment_praise;
drop table if exists course_comment_report;
drop table if exists course_evaluate;
drop table if exists course_praise;
drop table if exists course_recommend_data_model;
drop table if exists feedback;
drop table if exists question;
drop table if exists question_praise;
drop table if exists question_report;
drop table if exists system_message;
drop table if exists user;
drop table if exists video;
drop table if exists video_comment;
drop table if exists video_comment_report;
drop table if exists video_praise;
drop table if exists video_report;
/*==============================================================*/
/* Table: admins */
/*==============================================================*/
create table admins
(
admin_id int not null auto_increment,
account varchar(20),
password varchar(20),
primary key (admin_id)
);
/*==============================================================*/
/* Table: answer */
/*==============================================================*/
create table answer
(
answer_id int not null auto_increment,
ID varchar(40),
question_id int,
answer_content varchar(500),
answer_time varchar(30),
answer_isbanned bool,
answer_praise_point int,
primary key (answer_id)
);
/*==============================================================*/
/* Table: answer_praise */
/*==============================================================*/
create table answer_praise
(
answer_praise_id int not null auto_increment,
ID varchar(40),
answer_id int,
primary key (answer_praise_id)
);
/*==============================================================*/
/* Table: answer_report */
/*==============================================================*/
create table answer_report
(
answer_report_reason varchar(300),
answer_report_id int not null auto_increment,
ID varchar(40),
answer_id int,
answer_report_time varchar(30),
answer_report_ishandled bool,
primary key (answer_report_id)
);
/*==============================================================*/
/* Table: class_segments */
/*==============================================================*/
create table class_segments
(
classroom varchar(30),
begin_sec int,
end_sec int,
week int,
class_sec_id int not null auto_increment,
classname char(30),
begin_week int,
end_week int,
odd_or_even char(1),
primary key (class_sec_id)
);
/*==============================================================*/
/* Table: course */
/*==============================================================*/
create table course
(
course_id varchar(6) not null,
course_name varchar(200),
course_hours int,
course_credits int,
general bool,
general_type varchar(20),
course_deptname varchar(60),
course_praise_point int,
primary key (course_id)
);
/*==============================================================*/
/* Table: course_class */
/*==============================================================*/
create table course_class
(
teacher_id char(20),
teacher_name varchar(50),
teachers varchar(300),
classname char(30) not null,
course_id varchar(6),
course_participants int,
class_note varchar(1000),
year int,
semester int,
primary key (classname)
);
/*==============================================================*/
/* Table: course_comment */
/*==============================================================*/
create table course_comment
(
course_comment_content varchar(1000),
course_comment_time varchar(30),
course_comment_id int not null auto_increment,
course_id varchar(6),
ID varchar(40),
course_comment_isbanned bool,
course_comment_praise_point int,
primary key (course_comment_id)
);
/*==============================================================*/
/* Table: course_comment_praise */
/*==============================================================*/
create table course_comment_praise
(
course_comment_praise_id int not null auto_increment,
ID varchar(40),
course_comment_id int,
primary key (course_comment_praise_id)
);
/*==============================================================*/
/* Table: course_comment_report */
/*==============================================================*/
create table course_comment_report
(
course_comment_report_reason varchar(300),
course_comment_report_id int not null auto_increment,
course_comment_id int,
ID varchar(40),
course_comment_report_time varchar(30),
course_comment_report_ishandled bool,
primary key (course_comment_report_id)
);
/*==============================================================*/
/* Table: course_evaluate */
/*==============================================================*/
create table course_evaluate
(
course_evaluate_time varchar(30),
course_evaluate_id int not null auto_increment,
ID varchar(40),
course_id varchar(6),
course_evaluate_praise_point int,
course_evaluate_point int,
primary key (course_evaluate_id)
);
/*==============================================================*/
/* Table: course_praise */
/*==============================================================*/
create table course_praise
(
course_praise_id int not null auto_increment,
ID varchar(40),
course_id varchar(6),
primary key (course_praise_id)
);
/*==============================================================*/
/* Table: course_recommend_data_model */
/*==============================================================*/
create table course_recommend_data_model
(
recommend_id int not null,
user_id bigint,
lcourse_id bigint,
evaluate_point int,
evaluate_time bigint,
primary key (recommend_id)
);
/*==============================================================*/
/* Table: feedback */
/*==============================================================*/
create table feedback
(
ID varchar(40),
content varchar(3000),
time varchar(40),
feedback_id int not null auto_increment,
primary key (feedback_id)
);
/*==============================================================*/
/* Table: question */
/*==============================================================*/
create table question
(
question_id int not null auto_increment,
course_id varchar(6),
ID varchar(40),
question_content varchar(200),
question_time varchar(30),
question_isbanned bool,
question_praise_point int,
primary key (question_id)
);
/*==============================================================*/
/* Table: question_praise */
/*==============================================================*/
create table question_praise
(
question_praise_id int not null auto_increment,
ID varchar(40),
question_id int,
primary key (question_praise_id)
);
/*==============================================================*/
/* Table: question_report */
/*==============================================================*/
create table question_report
(
question_report_reason varchar(300),
question_report_id int not null auto_increment,
ID varchar(40),
question_id int,
question_report_time varchar(30),
question_report_ishandled bool,
primary key (question_report_id)
);
/*==============================================================*/
/* Table: system_message */
/*==============================================================*/
create table system_message
(
admin_id int,
content varchar(3000),
image_url varchar(30),
time varchar(40),
message_id int not null auto_increment,
primary key (message_id)
);
/*==============================================================*/
/* Table: user */
/*==============================================================*/
create table user
(
name varchar(20),
major varchar(40),
grade int,
sex char(1),
department varchar(40),
nickname varchar(20),
ID varchar(40) not null,
banned bool,
avatar_url varchar(100),
avator_url varchar(100),
primary key (ID)
);
/*==============================================================*/
/* Table: video */
/*==============================================================*/
create table video
(
video_id int not null auto_increment,
ID varchar(40),
post_time varchar(40),
post_text varchar(300),
video_url varchar(100),
type char(1),
image_url varchar(30),
isbanned bool,
video_praise_point int,
primary key (video_id)
);
/*==============================================================*/
/* Table: video_comment */
/*==============================================================*/
create table video_comment
(
video_comment_content varchar(300),
video_comment_time varchar(30),
video_comment_id int not null auto_increment,
ID varchar(40),
video_id int,
isbanned bool,
primary key (video_comment_id)
);
/*==============================================================*/
/* Table: video_comment_report */
/*==============================================================*/
create table video_comment_report
(
video_comment_report_reason varchar(300),
video_comment_report_id int not null auto_increment,
ID varchar(40),
video_comment_id int,
video_comment_report_time varchar(30),
video_comment_report_ishandled bool,
primary key (video_comment_report_id)
);
/*==============================================================*/
/* Table: video_praise */
/*==============================================================*/
create table video_praise
(
video_praise_id int not null auto_increment,
ID varchar(40),
video_id int,
primary key (video_praise_id)
);
/*==============================================================*/
/* Table: video_report */
/*==============================================================*/
create table video_report
(
video_report_reason varchar(300),
video_report_id int not null auto_increment,
ID varchar(40),
video_id int,
video_report_time varchar(30),
video_report_ishandled bool,
primary key (video_report_id)
);
alter table answer add constraint FK_Relationship_34 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table answer add constraint FK_Relationship_5 foreign key (question_id)
references question (question_id) on delete restrict on update restrict;
alter table answer_praise add constraint FK_Relationship_29 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table answer_praise add constraint FK_Relationship_30 foreign key (answer_id)
references answer (answer_id) on delete restrict on update restrict;
alter table answer_report add constraint FK_Relationship_11 foreign key (answer_id)
references answer (answer_id) on delete restrict on update restrict;
alter table answer_report add constraint FK_report_answer foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table class_segments add constraint FK_segment foreign key (classname)
references course_class (classname) on delete restrict on update restrict;
alter table course_class add constraint FK_Relationship_10 foreign key (course_id)
references course (course_id) on delete restrict on update restrict;
alter table course_comment add constraint FK_Relationship_3 foreign key (course_id)
references course (course_id) on delete restrict on update restrict;
alter table course_comment add constraint FK_post_course_comment foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table course_comment_praise add constraint FK_Relationship_23 foreign key (course_comment_id)
references course_comment (course_comment_id) on delete restrict on update restrict;
alter table course_comment_praise add constraint FK_Relationship_24 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table course_comment_report add constraint FK_Relationship_15 foreign key (course_comment_id)
references course_comment (course_comment_id) on delete restrict on update restrict;
alter table course_comment_report add constraint FK_reprot_course_comment foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table course_evaluate add constraint FK_Relationship_19 foreign key (course_id)
references course (course_id) on delete restrict on update restrict;
alter table course_evaluate add constraint FK_evaluate_course foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table course_praise add constraint FK_Relationship_25 foreign key (course_id)
references course (course_id) on delete restrict on update restrict;
alter table course_praise add constraint FK_Relationship_26 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table feedback add constraint FK_Relationship_36 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table question add constraint FK_Relationship_33 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table question add constraint FK_ask foreign key (course_id)
references course (course_id) on delete restrict on update restrict;
alter table question_praise add constraint FK_Relationship_27 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table question_praise add constraint FK_Relationship_28 foreign key (question_id)
references question (question_id) on delete restrict on update restrict;
alter table question_report add constraint FK_Relationship_13 foreign key (question_id)
references question (question_id) on delete restrict on update restrict;
alter table question_report add constraint FK_Relationship_14 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table system_message add constraint FK_Relationship_35 foreign key (admin_id)
references admins (admin_id) on delete restrict on update restrict;
alter table video add constraint FK_Relationship_22 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table video_comment add constraint FK_Relationship_7 foreign key (video_id)
references video (video_id) on delete restrict on update restrict;
alter table video_comment add constraint FK_post_video_comment foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table video_comment_report add constraint FK_Relationship_17 foreign key (video_comment_id)
references video_comment (video_comment_id) on delete restrict on update restrict;
alter table video_comment_report add constraint FK_Relationship_18 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table video_praise add constraint FK_Relationship_31 foreign key (ID)
references user (ID) on delete restrict on update restrict;
alter table video_praise add constraint FK_Relationship_32 foreign key (video_id)
references video (video_id) on delete restrict on update restrict;
alter table video_report add constraint FK_Relationship_8 foreign key (video_id)
references video (video_id) on delete restrict on update restrict;
alter table video_report add constraint FK_Relationship_9 foreign key (ID)
references user (ID) on delete restrict on update restrict;