-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
105 lines (94 loc) · 2.73 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
97
98
99
100
101
102
103
104
--drop type if exists course_level cascade;
--
--create type course_level as enum
-- ( 'G1'
-- , 'G2'
-- , 'A'
-- )
--;
drop table if exists queue cascade;
create table queue
( primary key (type, ref)
, type text not null
, ref text not null
, meta text
, prio double precision not null
, updated timestamptz not null default now()
)
;
drop index if exists queue_on_prio;
create index queue_on_prio on queue (prio);
drop table if exists programme cascade;
create table programme
( code text primary key
, name text not null
)
;
drop table if exists course cascade;
create table course
( code text primary key
, credits double precision not null
, level text not null
, name text not null
, updated timestamptz not null default now()
)
;
drop index if exists course_on_name_lower;
create index course_on_name_lower on course (lower(name));
drop table if exists course_relation;
create table course_relation
( primary key (code, programme, masters, validYear)
, code text not null references course
, programme text not null references programme
, type text not null
, masters text not null
, comment text not null
, programmeYear int not null
, validYear int not null
, periodical boolean not null
, lp1 boolean not null
, lp2 boolean not null
, lp3 boolean not null
, lp4 boolean not null
, constraint periodical_no_lp check
(not periodical or (not lp1 and not lp2 and not lp3 and not lp4))
, updated timestamptz not null default now()
)
;
drop index if exists course_relation_on_code;
create index course_relation_on_code on course_relation (code);
drop index if exists course_relation_on_programme_masters;
create index course_relation_on_programme_masters on course_relation (programme, masters);
drop index if exists course_relation_on_validYear;
create index course_relation_on_validYear on course_relation (validYear);
drop table if exists ceq cascade;
create table ceq
( primary key (code, year, semester, period)
, code text not null references course
, year int not null
, semester text not null
, period int not null
, url text not null
, registered int
, passed int
, responded int
, quality int
, goals int
, understanding int
, workload int
, relevance int
, satisfaction int
, updated timestamptz not null default now()
)
;
drop index if exists ceq_on_code;
create index ceq_on_code on ceq (code);
drop table if exists masters cascade;
create table masters
( primary key (programme, code)
, programme text not null references programme
, code text not null
, name text not null
, updated timestamptz not null default now()
)
;