on master help sign in
Add SQL syntax highlighting test
commit7a180e22ff37d0b078eb4b0135c51a1a71bacf0b authoruabua <mariami.chakhvadze.1@btu.edu.ge> dateMon 5 Oct 2020, 23:01 (6 years ago) parent3609700
2 files changed+532
tests/syntax-tests/highlighted/SQL/ims.sql+266 tests/syntax-tests/source/SQL/ims.sql+266
tests/syntax-tests/highlighted/SQL/ims.sqlnew file+266
@@ -0,0 +1,266 @@
1+-- interships
2+create table interships 
3+(intership_id number(7) constraint intership_id_pk primary key,
4+name varchar2(50),
5+start_date date,
6+end_date date);
7+
8+
9+insert into interships
10+values
11+ (1,
12+ 'Leaderator 2019',
13+ to_date('15/02/2019', 'DD/MM/YYYY'),
14+ to_date('01/09/2019', 'DD/MM/YYYY'));
15+
16+insert into interships
17+ (intership_id, name, start_date)
18+values
19+ (2, 'Leaderator 2020', to_date('10/02/2019', 'DD/MM/YYYY'));
20+
21+commit;
22+
23+-- directions
24+create table directions 
25+(direction_id number(7) constraint direction_id_pk primary key,
26+name varchar2(50));
27+
28+insert into directions values (1, 'Data Science');
29+
30+insert into directions values (2, 'Oracle Development');
31+
32+commit;
33+
34+-- participants
35+create table participants 
36+(participant_id number(7) constraint participant_id_pk primary key,
37+first_name varchar2(25),
38+last_name varchar2(25),
39+personal_id number(11),
40+intership_id number(7) constraint participant_inter_id_fk references interships (intership_id),
41+direction_id number(7) constraint participant_direct_id_fk references directions (direction_id),
42+constraint personal_id_unique unique (personal_id));
43+
44+insert into participants
45+values
46+ (1, 'Erekle', 'Tvinadze', 01011234567, 1, 1);
47+
48+insert into participants
49+values
50+ (2, 'Mariami', 'Chakhvadze', 01011234568, 2, 2);
51+
52+commit;
53+
54+-- hiring_layer_types
55+create table hiring_layer_types 
56+(layer_type_id number(7) constraint layer_id_pk primary key,
57+type varchar2(50));
58+
59+insert into hiring_layer_types values (1, 'GMAT');
60+
61+insert into hiring_layer_types values (2, 'Algorithms');
62+
63+insert into hiring_layer_types values (3, 'Interview');
64+
65+commit;
66+
67+-- hiring_layers
68+create table hiring_layers
69+(layer_id number(7) constraint layer_pk primary key,
70+layer_type_id number(7) constraint layer_type_fk references hiring_layer_types (layer_type_id),
71+participant_id number(7) constraint participant_id_fk references participants (participant_id),
72+result number(3));
73+
74+insert into hiring_layers values (1, 1, 1, 52);
75+
76+insert into hiring_layers values (2, 1, 2, 80);
77+
78+insert into hiring_layers values (3, 2, 2, 75);
79+
80+insert into hiring_layers values (4, 3, 2, 100);
81+
82+commit;
83+
84+-- subjects
85+create table subjects 
86+(subject_id number(7) constraint subject_id_pk primary key,
87+name varchar2(100),
88+minimum_score number(3));
89+
90+insert into subjects values (1, 'SQL', 70);
91+
92+insert into subjects values (2, 'Machine Learning', 70);
93+
94+commit;
95+
96+-- direction_subjects
97+create table direction_subjects
98+(direction_subject_id number(7) constraint direct_sub_id primary key,
99+direction_id number(7) constraint direct_id_fk references directions (direction_id),
100+subject_id number(7) constraint subject_id_fk references subjects (subject_id));
101+
102+insert into direction_subjects values (1, 2, 1);
103+
104+insert into direction_subjects values (2, 1, 1);
105+
106+insert into direction_subjects values (3, 1, 2);
107+
108+commit;
109+
110+-- component_types
111+create table component_types
112+(component_type_id number(7) constraint com_type_id_pk primary key,
113+type varchar2(50));
114+
115+insert into component_types values (1, 'Homework');
116+
117+insert into component_types values (2, 'Quiz');
118+
119+commit;
120+
121+-- components
122+create table components
123+(component_id number(7) constraint component_id_pk primary key,
124+subject_id number(7) constraint sub_id_fk references subjects (subject_id),
125+minimum_score number(3),
126+component_type_id number(7) constraint com_type_id_fk references component_types (component_type_id),
127+weight number(3));
128+
129+insert into components values (1, 1, 60, 1, 20);
130+
131+insert into components values (2, 2, 65, 2, 50);
132+
133+commit;
134+
135+-- results
136+create table results 
137+(result_id number(7) constraint result_id_pk primary key,
138+issue_date date,
139+grade number(3),
140+participant_id number(7) constraint particip_id_fk references participants (participant_id),
141+component_id number(7) constraint component_id_fk references components (component_id));
142+
143+insert into results
144+values
145+ (1, to_date('04/05/2020', 'DD/MM/YYYY'), 87, 2, 2);
146+
147+commit;
148+
149+-- learning_material_types
150+create table learning_material_types
151+(material_type_id number(7) constraint lear_material_id_pk primary key,
152+type varchar(50));
153+
154+insert into learning_material_types values (1, 'Book');
155+
156+insert into learning_material_types values (2, 'PPT');
157+
158+insert into learning_material_types values (3, 'Youtube Video');
159+
160+commit;
161+
162+-- learning_materials
163+create table learning_materials
164+(learning_material_id number(7),
165+url varchar2(3000),
166+subject_id number(7) constraint subj_id_fk references subjects (subject_id),
167+material_type_id number(7) constraint material_type_id_fk references learning_material_types (material_type_id));
168+
169+insert into learning_materials values (1, 'www.youtube.com', 1, 3);
170+
171+commit;
172+
173+-- sessions
174+create table sessions 
175+(session_id number(7) constraint session_id_pk primary key,
176+start_date date,
177+end_date date,
178+intership_id number(7) constraint inter_idd_fk references interships (intership_id),
179+direction_id number(7) constraint direct_fk references directions (direction_id),
180+subject_id number(7) constraint subject_fk references subjects (subject_id));
181+
182+-- attendances
183+create table attendances
184+(attendance_id number(7) constraint attend_id_pk primary key,
185+participant_id number(7) constraint participant_fk references participants (participant_id),
186+session_id number(7) constraint session_id_fk references sessions (session_id),
187+status varchar2(25));
188+
189+
190+/*
191+შექმენით view სადაც იქნება სტაჟირების შესახებ ინფორმაცია:
192+სახელი,
193+დაწყების თარიღი,
194+დასრულების თარიღი,
195+მონაწილეების რაოდენობა.
196+*/
197+create view intership_info
198+as select i.name, i.start_date, i.end_date, (select count(participant_id) from participants p where p.intership_id = i.intership_id) number_of_participants
199+from interships i;
200+
201+/*
202+შექმენით view სადაც იქნება მონაწილეებზე ინფორმაცია:
203+სტაჟირების სახელი,
204+მონაწილის სახელი,
205+მიმართულება,
206+შერჩევის რამდენი ეტაპი გაიარა,
207+სტაჟირების სტატუსი(გაიარა, ვერ გაიარა, მიმდინარე,ვერ მოხვდა სტაჟირებაზე)
208+*/
209+create view participant_info
210+as select i.name intership, p.first_name, p.last_name, d.name direction, 
211+(select count(h2.participant_id) from hiring_layers h2 where h2.participant_id = p.participant_id) number_of_layers,
212+case when p.direction_id is null then 'Rejected'
213+ when i.end_date is null then 'Present'
214+ when (select h2.result from hiring_layers h2 join hiring_layer_types l on h2.layer_type_id = l.layer_type_id where h2.participant_id = p.participant_id and l.type = 'Intership') > (select minimum_score from subjects) then 'Passed'
215+ else 'Failed'
216+ end status
217+from interships i,
218+participants p,
219+directions d
220+where i.intership_id = p.intership_id
221+and (d.direction_id = p.direction_id or p.direction_id is null);
222+
223+/*
224+შექნენით view სადაც იქნება მიმართულებებზე ინფორმაცია:
225+მიმართულების სახელი,
226+რა საგნები ისწავლება
227+*/
228+create view direction_info
229+as select d.name direction, s.name subject
230+from directions d,
231+direction_subjects ds,
232+subjects s
233+where d.direction_id = ds.direction_id
234+and ds.subject_id = s.subject_id;
235+
236+/*
237+შექმენით view სადც იქნება საგნების ინფორმაცია:
238+საგნის სახელი,
239+საგნის ზღვარი,
240+შეფასების კომპონენტები(სახელი, ზღვარი , წონა).
241+*/
242+create view subject_info
243+as select s.name, s.minimum_score subject_min_score, ct.type, c.minimum_score component_min_score, c.weight
244+from subjects s,
245+component_types ct,
246+components c
247+where s.subject_id = c.subject_id 
248+and c.component_type_id = ct.component_type_id;
249+
250+/*
251+შექმენით view დასწრების აღრიცხვა მონაწილეების მიხედვით:
252+სტაჟირებაზე მიმართულების მიხედვით:
253+რამდენი ჩატარდა,
254+რამდენს დაესწრო,
255+რამდენს არ დაესწრო.
256+*/
257+create view attendance_info
258+as select p.first_name, p.last_name, 
259+(select count(s2.session_id) from sessions s2 where s2.direction_id = p.direction_id) lectures,
260+(select count(a2.attendance_id) from attendances a2 where a2.participant_id = p.participant_id and a2.status = 'Present') present,
261+(select count(a2.attendance_id) from attendances a2 where a2.participant_id = p.participant_id and a2.status = 'Absent') absent
262+from participants p,
263+attendances a,
264+sessions s
265+where p.participant_id = a.participant_id
266+and a.session_id = s.session_id;
tests/syntax-tests/source/SQL/ims.sqlnew file+266
@@ -0,0 +1,266 @@
1+-- interships
2+create table interships
3+(intership_id number(7) constraint intership_id_pk primary key,
4+name varchar2(50),
5+start_date date,
6+end_date date);
7+
8+
9+insert into interships
10+values
11+ (1,
12+ 'Leaderator 2019',
13+ to_date('15/02/2019', 'DD/MM/YYYY'),
14+ to_date('01/09/2019', 'DD/MM/YYYY'));
15+
16+insert into interships
17+ (intership_id, name, start_date)
18+values
19+ (2, 'Leaderator 2020', to_date('10/02/2019', 'DD/MM/YYYY'));
20+
21+commit;
22+
23+-- directions
24+create table directions
25+(direction_id number(7) constraint direction_id_pk primary key,
26+name varchar2(50));
27+
28+insert into directions values (1, 'Data Science');
29+
30+insert into directions values (2, 'Oracle Development');
31+
32+commit;
33+
34+-- participants
35+create table participants
36+(participant_id number(7) constraint participant_id_pk primary key,
37+first_name varchar2(25),
38+last_name varchar2(25),
39+personal_id number(11),
40+intership_id number(7) constraint participant_inter_id_fk references interships (intership_id),
41+direction_id number(7) constraint participant_direct_id_fk references directions (direction_id),
42+constraint personal_id_unique unique (personal_id));
43+
44+insert into participants
45+values
46+ (1, 'Erekle', 'Tvinadze', 01011234567, 1, 1);
47+
48+insert into participants
49+values
50+ (2, 'Mariami', 'Chakhvadze', 01011234568, 2, 2);
51+
52+commit;
53+
54+-- hiring_layer_types
55+create table hiring_layer_types
56+(layer_type_id number(7) constraint layer_id_pk primary key,
57+type varchar2(50));
58+
59+insert into hiring_layer_types values (1, 'GMAT');
60+
61+insert into hiring_layer_types values (2, 'Algorithms');
62+
63+insert into hiring_layer_types values (3, 'Interview');
64+
65+commit;
66+
67+-- hiring_layers
68+create table hiring_layers
69+(layer_id number(7) constraint layer_pk primary key,
70+layer_type_id number(7) constraint layer_type_fk references hiring_layer_types (layer_type_id),
71+participant_id number(7) constraint participant_id_fk references participants (participant_id),
72+result number(3));
73+
74+insert into hiring_layers values (1, 1, 1, 52);
75+
76+insert into hiring_layers values (2, 1, 2, 80);
77+
78+insert into hiring_layers values (3, 2, 2, 75);
79+
80+insert into hiring_layers values (4, 3, 2, 100);
81+
82+commit;
83+
84+-- subjects
85+create table subjects
86+(subject_id number(7) constraint subject_id_pk primary key,
87+name varchar2(100),
88+minimum_score number(3));
89+
90+insert into subjects values (1, 'SQL', 70);
91+
92+insert into subjects values (2, 'Machine Learning', 70);
93+
94+commit;
95+
96+-- direction_subjects
97+create table direction_subjects
98+(direction_subject_id number(7) constraint direct_sub_id primary key,
99+direction_id number(7) constraint direct_id_fk references directions (direction_id),
100+subject_id number(7) constraint subject_id_fk references subjects (subject_id));
101+
102+insert into direction_subjects values (1, 2, 1);
103+
104+insert into direction_subjects values (2, 1, 1);
105+
106+insert into direction_subjects values (3, 1, 2);
107+
108+commit;
109+
110+-- component_types
111+create table component_types
112+(component_type_id number(7) constraint com_type_id_pk primary key,
113+type varchar2(50));
114+
115+insert into component_types values (1, 'Homework');
116+
117+insert into component_types values (2, 'Quiz');
118+
119+commit;
120+
121+-- components
122+create table components
123+(component_id number(7) constraint component_id_pk primary key,
124+subject_id number(7) constraint sub_id_fk references subjects (subject_id),
125+minimum_score number(3),
126+component_type_id number(7) constraint com_type_id_fk references component_types (component_type_id),
127+weight number(3));
128+
129+insert into components values (1, 1, 60, 1, 20);
130+
131+insert into components values (2, 2, 65, 2, 50);
132+
133+commit;
134+
135+-- results
136+create table results
137+(result_id number(7) constraint result_id_pk primary key,
138+issue_date date,
139+grade number(3),
140+participant_id number(7) constraint particip_id_fk references participants (participant_id),
141+component_id number(7) constraint component_id_fk references components (component_id));
142+
143+insert into results
144+values
145+ (1, to_date('04/05/2020', 'DD/MM/YYYY'), 87, 2, 2);
146+
147+commit;
148+
149+-- learning_material_types
150+create table learning_material_types
151+(material_type_id number(7) constraint lear_material_id_pk primary key,
152+type varchar(50));
153+
154+insert into learning_material_types values (1, 'Book');
155+
156+insert into learning_material_types values (2, 'PPT');
157+
158+insert into learning_material_types values (3, 'Youtube Video');
159+
160+commit;
161+
162+-- learning_materials
163+create table learning_materials
164+(learning_material_id number(7),
165+url varchar2(3000),
166+subject_id number(7) constraint subj_id_fk references subjects (subject_id),
167+material_type_id number(7) constraint material_type_id_fk references learning_material_types (material_type_id));
168+
169+insert into learning_materials values (1, 'www.youtube.com', 1, 3);
170+
171+commit;
172+
173+-- sessions
174+create table sessions
175+(session_id number(7) constraint session_id_pk primary key,
176+start_date date,
177+end_date date,
178+intership_id number(7) constraint inter_idd_fk references interships (intership_id),
179+direction_id number(7) constraint direct_fk references directions (direction_id),
180+subject_id number(7) constraint subject_fk references subjects (subject_id));
181+
182+-- attendances
183+create table attendances
184+(attendance_id number(7) constraint attend_id_pk primary key,
185+participant_id number(7) constraint participant_fk references participants (participant_id),
186+session_id number(7) constraint session_id_fk references sessions (session_id),
187+status varchar2(25));
188+
189+
190+/*
191+შექმენით view სადაც იქნება სტაჟირების შესახებ ინფორმაცია:
192+სახელი,
193+დაწყების თარიღი,
194+დასრულების თარიღი,
195+მონაწილეების რაოდენობა.
196+*/
197+create view intership_info
198+as select i.name, i.start_date, i.end_date, (select count(participant_id) from participants p where p.intership_id = i.intership_id) number_of_participants
199+from interships i;
200+
201+/*
202+შექმენით view სადაც იქნება მონაწილეებზე ინფორმაცია:
203+სტაჟირების სახელი,
204+მონაწილის სახელი,
205+მიმართულება,
206+შერჩევის რამდენი ეტაპი გაიარა,
207+სტაჟირების სტატუსი(გაიარა, ვერ გაიარა, მიმდინარე,ვერ მოხვდა სტაჟირებაზე)
208+*/
209+create view participant_info
210+as select i.name intership, p.first_name, p.last_name, d.name direction,
211+(select count(h2.participant_id) from hiring_layers h2 where h2.participant_id = p.participant_id) number_of_layers,
212+case when p.direction_id is null then 'Rejected'
213+ when i.end_date is null then 'Present'
214+ when (select h2.result from hiring_layers h2 join hiring_layer_types l on h2.layer_type_id = l.layer_type_id where h2.participant_id = p.participant_id and l.type = 'Intership') > (select minimum_score from subjects) then 'Passed'
215+ else 'Failed'
216+ end status
217+from interships i,
218+participants p,
219+directions d
220+where i.intership_id = p.intership_id
221+and (d.direction_id = p.direction_id or p.direction_id is null);
222+
223+/*
224+შექნენით view სადაც იქნება მიმართულებებზე ინფორმაცია:
225+მიმართულების სახელი,
226+რა საგნები ისწავლება
227+*/
228+create view direction_info
229+as select d.name direction, s.name subject
230+from directions d,
231+direction_subjects ds,
232+subjects s
233+where d.direction_id = ds.direction_id
234+and ds.subject_id = s.subject_id;
235+
236+/*
237+შექმენით view სადც იქნება საგნების ინფორმაცია:
238+საგნის სახელი,
239+საგნის ზღვარი,
240+შეფასების კომპონენტები(სახელი, ზღვარი , წონა).
241+*/
242+create view subject_info
243+as select s.name, s.minimum_score subject_min_score, ct.type, c.minimum_score component_min_score, c.weight
244+from subjects s,
245+component_types ct,
246+components c
247+where s.subject_id = c.subject_id
248+and c.component_type_id = ct.component_type_id;
249+
250+/*
251+შექმენით view დასწრების აღრიცხვა მონაწილეების მიხედვით:
252+სტაჟირებაზე მიმართულების მიხედვით:
253+რამდენი ჩატარდა,
254+რამდენს დაესწრო,
255+რამდენს არ დაესწრო.
256+*/
257+create view attendance_info
258+as select p.first_name, p.last_name,
259+(select count(s2.session_id) from sessions s2 where s2.direction_id = p.direction_id) lectures,
260+(select count(a2.attendance_id) from attendances a2 where a2.participant_id = p.participant_id and a2.status = 'Present') present,
261+(select count(a2.attendance_id) from attendances a2 where a2.participant_id = p.participant_id and a2.status = 'Absent') absent
262+from participants p,
263+attendances a,
264+sessions s
265+where p.participant_id = a.participant_id
266+and a.session_id = s.session_id;