-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
96 lines (78 loc) · 2.2 KB
/
schema.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
pragma foreign_keys = on;
pragma encoding = "UTF-8";
create table Administrator (
Email text primary key not null,
Name text not null
);
create table Instructor (
Email text primary key not null,
Name text not null
);
create table Student (
Email text primary key not null,
Name text not null
);
create table Course (
Tag text primary key not null,
Name text not null,
Close timestamp not null
);
create table CourseInstructor (
Course text not null,
Instructor text not null,
primary key (Course, Instructor),
foreign key (Course) references Course(Tag),
foreign key (Instructor) references Instructor(Email)
);
create table CourseStudent (
Course text not null,
Student text not null,
primary key (Course, Student),
foreign key (Course) references Course(Tag),
foreign key (Student) references Student(Email)
);
create table Problem (
ID integer primary key autoincrement,
Name text not null,
Type text not null,
Data text not null
);
create table Tag (
Tag text primary key not null,
Description text,
Priority integer not null default 0
);
create table ProblemTag (
Problem integer not null,
Tag text not null,
primary key (Problem, Tag),
foreign key (Problem) references Problem(ID),
foreign key (Tag) references Tag(Tag)
);
create table Assignment (
ID integer primary key autoincrement,
Course text not null,
Problem integer not null,
ForCredit integer not null,
Open timestamp not null,
Close timestamp not null,
foreign key (Course) references Course (Tag),
foreign key (Problem) references Problem (ID)
);
create table Solution (
ID integer primary key autoincrement,
Student text not null,
Assignment integer not null,
foreign key (Student) references Student (Email),
foreign key (Assignment) references Assignment (ID)
);
create table Submission (
Solution integer not null,
TimeStamp timestamp not null,
Submission text not null,
GradeReport text not null,
Passed integer,
primary key (Solution, TimeStamp),
foreign key (Solution) references Solution (ID)
);
create index submission_timestamp on Submission (TimeStamp);