-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.sql
997 lines (677 loc) · 24.8 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
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.3 (Debian 15.3-1.pgdg120+1)
-- Dumped by pg_dump version 15.3 (Debian 15.3-1.pgdg120+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: announcement_category_enum; Type: TYPE; Schema: public; Owner: root
--
CREATE TYPE public.announcement_category_enum AS ENUM (
'event',
'general',
'academic'
);
ALTER TYPE public.announcement_category_enum OWNER TO root;
--
-- Name: audience_enum; Type: TYPE; Schema: public; Owner: root
--
CREATE TYPE public.audience_enum AS ENUM (
'teachers',
'parents',
'students',
'groups'
);
ALTER TYPE public.audience_enum OWNER TO root;
--
-- Name: day_of_week_enum; Type: TYPE; Schema: public; Owner: root
--
CREATE TYPE public.day_of_week_enum AS ENUM (
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday',
'sunday'
);
ALTER TYPE public.day_of_week_enum OWNER TO root;
--
-- Name: performance_level_enum; Type: TYPE; Schema: public; Owner: root
--
CREATE TYPE public.performance_level_enum AS ENUM (
'exceeds_expectations',
'meets_expectations',
'needs_improvement',
'below_expectations',
'not_yet_meeting_expectations'
);
ALTER TYPE public.performance_level_enum OWNER TO root;
--
-- Name: person_type_enum; Type: TYPE; Schema: public; Owner: root
--
CREATE TYPE public.person_type_enum AS ENUM (
'teacher',
'parent',
'student',
'not_defined'
);
ALTER TYPE public.person_type_enum OWNER TO root;
--
-- Name: time_table_item_type_enum; Type: TYPE; Schema: public; Owner: root
--
CREATE TYPE public.time_table_item_type_enum AS ENUM (
'activity',
'lecture',
'event'
);
ALTER TYPE public.time_table_item_type_enum OWNER TO root;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: activities; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.activities (
id uuid DEFAULT gen_random_uuid() NOT NULL,
activity_title text,
activity_description text,
activity_type text,
time_table_id uuid
);
ALTER TABLE public.activities OWNER TO root;
--
-- Name: announcements; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.announcements (
id uuid DEFAULT gen_random_uuid() NOT NULL,
title character varying NOT NULL,
description text,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
start_date timestamp without time zone,
end_date timestamp without time zone,
category public.announcement_category_enum NOT NULL,
targets uuid[],
attachements timestamp without time zone,
important boolean,
audience public.audience_enum
);
ALTER TABLE public.announcements OWNER TO root;
--
-- Name: assignments; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.assignments (
id uuid DEFAULT gen_random_uuid() NOT NULL,
title character varying NOT NULL,
description character varying NOT NULL,
due_date timestamp without time zone NOT NULL,
submission_type character varying NOT NULL,
gradin_rubric_id uuid,
file character varying,
teacher_id uuid,
subject_id uuid
);
ALTER TABLE public.assignments OWNER TO root;
--
-- Name: classes; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.classes (
id uuid DEFAULT gen_random_uuid() NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
subject_id uuid,
teacher_id uuid,
group_id uuid,
room_id uuid,
md_idx character varying GENERATED ALWAYS AS (md5(((((((((subject_id)::character varying)::text || '-'::text) || ((teacher_id)::character varying)::text) || '-'::text) || ((group_id)::character varying)::text) || '-'::text) || ((room_id)::character varying)::text))) STORED
);
ALTER TABLE public.classes OWNER TO root;
--
-- Name: disciplinary_actions; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.disciplinary_actions (
id uuid DEFAULT gen_random_uuid() NOT NULL,
student_id uuid NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
issued_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
description text NOT NULL,
consequences text NOT NULL
);
ALTER TABLE public.disciplinary_actions OWNER TO root;
--
-- Name: events; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.events (
id uuid DEFAULT gen_random_uuid() NOT NULL,
event_title text,
event_description text,
time_table_id uuid
);
ALTER TABLE public.events OWNER TO root;
--
-- Name: grades; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.grades (
id uuid DEFAULT gen_random_uuid() NOT NULL,
student_id uuid NOT NULL,
assignment_id uuid NOT NULL,
score real NOT NULL,
feedback character varying
);
ALTER TABLE public.grades OWNER TO root;
--
-- Name: grading_criteria; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.grading_criteria (
id uuid DEFAULT gen_random_uuid() NOT NULL,
grading_rubric_id uuid NOT NULL,
description character varying,
performance public.performance_level_enum NOT NULL
);
ALTER TABLE public.grading_criteria OWNER TO root;
--
-- Name: grading_rubrics; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.grading_rubrics (
id uuid DEFAULT gen_random_uuid() NOT NULL,
title character varying NOT NULL,
description character varying
);
ALTER TABLE public.grading_rubrics OWNER TO root;
--
-- Name: group_assignments; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.group_assignments (
id uuid DEFAULT gen_random_uuid() NOT NULL,
group_id uuid,
assignment_id uuid
);
ALTER TABLE public.group_assignments OWNER TO root;
--
-- Name: groups; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.groups (
id uuid DEFAULT gen_random_uuid() NOT NULL,
group_name character varying NOT NULL,
group_description character varying,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
level_id uuid
);
ALTER TABLE public.groups OWNER TO root;
--
-- Name: lectures; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.lectures (
id uuid DEFAULT gen_random_uuid() NOT NULL,
class_id uuid,
time_table_id uuid
);
ALTER TABLE public.lectures OWNER TO root;
--
-- Name: levels; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.levels (
id uuid DEFAULT gen_random_uuid() NOT NULL,
level_name character varying NOT NULL,
level_description character varying,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE public.levels OWNER TO root;
--
-- Name: parents; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.parents (
id uuid DEFAULT gen_random_uuid() NOT NULL,
first_name character varying NOT NULL,
last_name character varying NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
full_name character varying GENERATED ALWAYS AS ((((first_name)::text || ' '::text) || (last_name)::text)) STORED,
person_id uuid
);
ALTER TABLE public.parents OWNER TO root;
--
-- Name: persons; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.persons (
id uuid DEFAULT gen_random_uuid() NOT NULL,
person_type public.person_type_enum NOT NULL
);
ALTER TABLE public.persons OWNER TO root;
--
-- Name: pickups; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.pickups (
id uuid DEFAULT gen_random_uuid() NOT NULL,
student_id uuid NOT NULL,
parent_id uuid NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
ALTER TABLE public.pickups OWNER TO root;
--
-- Name: rooms; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.rooms (
id uuid DEFAULT gen_random_uuid() NOT NULL,
room_name character varying NOT NULL,
room_description character varying
);
ALTER TABLE public.rooms OWNER TO root;
--
-- Name: scans; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.scans (
id uuid DEFAULT gen_random_uuid() NOT NULL,
scan_date timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
person_id uuid NOT NULL
);
ALTER TABLE public.scans OWNER TO root;
--
-- Name: seaql_migrations; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.seaql_migrations (
version character varying NOT NULL,
applied_at bigint NOT NULL
);
ALTER TABLE public.seaql_migrations OWNER TO root;
--
-- Name: sessions; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.sessions (
id uuid NOT NULL,
user_id uuid NOT NULL,
user_agent character varying NOT NULL,
client_ip character varying NOT NULL,
is_blocked boolean DEFAULT false NOT NULL,
refresh_token character varying NOT NULL,
expires_at timestamp without time zone NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
ALTER TABLE public.sessions OWNER TO root;
--
-- Name: students; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.students (
id uuid DEFAULT gen_random_uuid() NOT NULL,
first_name character varying NOT NULL,
last_name character varying NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
full_name character varying GENERATED ALWAYS AS ((((first_name)::text || ' '::text) || (last_name)::text)) STORED,
person_id uuid,
group_id uuid
);
ALTER TABLE public.students OWNER TO root;
--
-- Name: subjects; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.subjects (
id uuid DEFAULT gen_random_uuid() NOT NULL,
subject_name character varying NOT NULL,
subject_description character varying,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
level_id uuid
);
ALTER TABLE public.subjects OWNER TO root;
--
-- Name: teacher_subjects; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.teacher_subjects (
id uuid DEFAULT gen_random_uuid() NOT NULL,
subject_id uuid,
teacher_id uuid,
md_idx character varying GENERATED ALWAYS AS (md5(((((subject_id)::character varying)::text || '-'::text) || ((teacher_id)::character varying)::text))) STORED
);
ALTER TABLE public.teacher_subjects OWNER TO root;
--
-- Name: teachers; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.teachers (
id uuid DEFAULT gen_random_uuid() NOT NULL,
first_name character varying NOT NULL,
last_name character varying NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
full_name character varying GENERATED ALWAYS AS ((((first_name)::text || ' '::text) || (last_name)::text)) STORED,
person_id uuid,
level_id uuid
);
ALTER TABLE public.teachers OWNER TO root;
--
-- Name: time_table; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.time_table (
id uuid DEFAULT gen_random_uuid() NOT NULL,
item_type public.time_table_item_type_enum NOT NULL,
day_of_week public.day_of_week_enum,
full_date date,
start_time time without time zone,
end_time time without time zone
);
ALTER TABLE public.time_table OWNER TO root;
--
-- Name: users; Type: TABLE; Schema: public; Owner: root
--
CREATE TABLE public.users (
id uuid DEFAULT gen_random_uuid() NOT NULL,
email character varying NOT NULL,
first_name character varying NOT NULL,
last_name character varying NOT NULL,
full_name character varying GENERATED ALWAYS AS ((((first_name)::text || ' '::text) || (last_name)::text)) STORED,
person_id uuid NOT NULL,
picture character varying
);
ALTER TABLE public.users OWNER TO root;
--
-- Name: activities activities_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.activities
ADD CONSTRAINT activities_pkey PRIMARY KEY (id);
--
-- Name: announcements announcements_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.announcements
ADD CONSTRAINT announcements_pkey PRIMARY KEY (id);
--
-- Name: assignments assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.assignments
ADD CONSTRAINT assignments_pkey PRIMARY KEY (id);
--
-- Name: classes classes_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT classes_pkey PRIMARY KEY (id);
--
-- Name: disciplinary_actions disciplinary_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.disciplinary_actions
ADD CONSTRAINT disciplinary_actions_pkey PRIMARY KEY (id);
--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT events_pkey PRIMARY KEY (id);
--
-- Name: grades grades_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.grades
ADD CONSTRAINT grades_pkey PRIMARY KEY (id);
--
-- Name: grading_criteria grading_criteria_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.grading_criteria
ADD CONSTRAINT grading_criteria_pkey PRIMARY KEY (id);
--
-- Name: grading_rubrics grading_rubrics_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.grading_rubrics
ADD CONSTRAINT grading_rubrics_pkey PRIMARY KEY (id);
--
-- Name: group_assignments group_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.group_assignments
ADD CONSTRAINT group_assignments_pkey PRIMARY KEY (id);
--
-- Name: groups groups_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.groups
ADD CONSTRAINT groups_pkey PRIMARY KEY (id);
--
-- Name: lectures lectures_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.lectures
ADD CONSTRAINT lectures_pkey PRIMARY KEY (id);
--
-- Name: levels levels_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.levels
ADD CONSTRAINT levels_pkey PRIMARY KEY (id);
--
-- Name: parents parents_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.parents
ADD CONSTRAINT parents_pkey PRIMARY KEY (id);
--
-- Name: persons persons_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.persons
ADD CONSTRAINT persons_pkey PRIMARY KEY (id);
--
-- Name: pickups pickups_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.pickups
ADD CONSTRAINT pickups_pkey PRIMARY KEY (id);
--
-- Name: rooms rooms_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.rooms
ADD CONSTRAINT rooms_pkey PRIMARY KEY (id);
--
-- Name: scans scans_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.scans
ADD CONSTRAINT scans_pkey PRIMARY KEY (id);
--
-- Name: seaql_migrations seaql_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.seaql_migrations
ADD CONSTRAINT seaql_migrations_pkey PRIMARY KEY (version);
--
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.sessions
ADD CONSTRAINT sessions_pkey PRIMARY KEY (id);
--
-- Name: students students_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.students
ADD CONSTRAINT students_pkey PRIMARY KEY (id);
--
-- Name: subjects subjects_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.subjects
ADD CONSTRAINT subjects_pkey PRIMARY KEY (id);
--
-- Name: teacher_subjects teacher_subjects_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.teacher_subjects
ADD CONSTRAINT teacher_subjects_pkey PRIMARY KEY (id);
--
-- Name: teachers teachers_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.teachers
ADD CONSTRAINT teachers_pkey PRIMARY KEY (id);
--
-- Name: time_table time_table_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.time_table
ADD CONSTRAINT time_table_pkey PRIMARY KEY (id);
--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: idx_class_md_idx; Type: INDEX; Schema: public; Owner: root
--
CREATE UNIQUE INDEX idx_class_md_idx ON public.classes USING btree (md_idx);
--
-- Name: idx_parents_full_name; Type: INDEX; Schema: public; Owner: root
--
CREATE INDEX idx_parents_full_name ON public.parents USING btree (full_name);
--
-- Name: idx_students_full_name; Type: INDEX; Schema: public; Owner: root
--
CREATE INDEX idx_students_full_name ON public.students USING btree (full_name);
--
-- Name: idx_teachers_full_name; Type: INDEX; Schema: public; Owner: root
--
CREATE INDEX idx_teachers_full_name ON public.teachers USING btree (full_name);
--
-- Name: activities fk_activities_time_table_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.activities
ADD CONSTRAINT fk_activities_time_table_id FOREIGN KEY (time_table_id) REFERENCES public.time_table(id) ON DELETE CASCADE;
--
-- Name: assignments fk_assignment_rubric_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.assignments
ADD CONSTRAINT fk_assignment_rubric_id FOREIGN KEY (gradin_rubric_id) REFERENCES public.grading_rubrics(id) ON DELETE CASCADE;
--
-- Name: assignments fk_assignment_subject_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.assignments
ADD CONSTRAINT fk_assignment_subject_id FOREIGN KEY (gradin_rubric_id) REFERENCES public.subjects(id) ON DELETE SET NULL;
--
-- Name: assignments fk_assignment_teacher_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.assignments
ADD CONSTRAINT fk_assignment_teacher_id FOREIGN KEY (gradin_rubric_id) REFERENCES public.teachers(id) ON DELETE SET NULL;
--
-- Name: classes fk_classes_group_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT fk_classes_group_id FOREIGN KEY (group_id) REFERENCES public.groups(id) ON DELETE CASCADE;
--
-- Name: classes fk_classes_room_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT fk_classes_room_id FOREIGN KEY (room_id) REFERENCES public.rooms(id) ON DELETE CASCADE;
--
-- Name: classes fk_classes_subject_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT fk_classes_subject_id FOREIGN KEY (subject_id) REFERENCES public.subjects(id) ON DELETE SET NULL;
--
-- Name: classes fk_classes_teacher_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.classes
ADD CONSTRAINT fk_classes_teacher_id FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;
--
-- Name: groups fk_details_person_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.groups
ADD CONSTRAINT fk_details_person_id FOREIGN KEY (level_id) REFERENCES public.levels(id) ON DELETE CASCADE;
--
-- Name: disciplinary_actions fk_disciplinary_actions_student_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.disciplinary_actions
ADD CONSTRAINT fk_disciplinary_actions_student_id FOREIGN KEY (student_id) REFERENCES public.students(id) ON DELETE RESTRICT;
--
-- Name: events fk_events_time_table_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT fk_events_time_table_id FOREIGN KEY (time_table_id) REFERENCES public.time_table(id) ON DELETE CASCADE;
--
-- Name: grades fk_grade_assignment_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.grades
ADD CONSTRAINT fk_grade_assignment_id FOREIGN KEY (assignment_id) REFERENCES public.assignments(id) ON DELETE RESTRICT;
--
-- Name: grades fk_grade_student_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.grades
ADD CONSTRAINT fk_grade_student_id FOREIGN KEY (student_id) REFERENCES public.students(id) ON DELETE RESTRICT;
--
-- Name: grading_criteria fk_grading_criteria_rubrics_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.grading_criteria
ADD CONSTRAINT fk_grading_criteria_rubrics_id FOREIGN KEY (grading_rubric_id) REFERENCES public.grading_rubrics(id) ON DELETE CASCADE;
--
-- Name: group_assignments fk_group_assignments_assignment_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.group_assignments
ADD CONSTRAINT fk_group_assignments_assignment_id FOREIGN KEY (group_id) REFERENCES public.assignments(id) ON DELETE SET NULL;
--
-- Name: group_assignments fk_group_assignments_group_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.group_assignments
ADD CONSTRAINT fk_group_assignments_group_id FOREIGN KEY (group_id) REFERENCES public.groups(id) ON DELETE SET NULL;
--
-- Name: lectures fk_lectures_class_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.lectures
ADD CONSTRAINT fk_lectures_class_id FOREIGN KEY (class_id) REFERENCES public.classes(id) ON DELETE CASCADE;
--
-- Name: lectures fk_lectures_time_table_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.lectures
ADD CONSTRAINT fk_lectures_time_table_id FOREIGN KEY (time_table_id) REFERENCES public.time_table(id) ON DELETE CASCADE;
--
-- Name: parents fk_parent_person_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.parents
ADD CONSTRAINT fk_parent_person_id FOREIGN KEY (person_id) REFERENCES public.persons(id);
--
-- Name: pickups fk_pickup_parent_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.pickups
ADD CONSTRAINT fk_pickup_parent_id FOREIGN KEY (parent_id) REFERENCES public.parents(id) ON DELETE CASCADE;
--
-- Name: pickups fk_pickup_student_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.pickups
ADD CONSTRAINT fk_pickup_student_id FOREIGN KEY (student_id) REFERENCES public.students(id) ON DELETE CASCADE;
--
-- Name: scans fk_scan_person_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.scans
ADD CONSTRAINT fk_scan_person_id FOREIGN KEY (person_id) REFERENCES public.persons(id);
--
-- Name: sessions fk_sessions_user_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.sessions
ADD CONSTRAINT fk_sessions_user_id FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE RESTRICT;
--
-- Name: students fk_student_group_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.students
ADD CONSTRAINT fk_student_group_id FOREIGN KEY (group_id) REFERENCES public.groups(id);
--
-- Name: students fk_student_person_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.students
ADD CONSTRAINT fk_student_person_id FOREIGN KEY (person_id) REFERENCES public.persons(id);
--
-- Name: subjects fk_subject_level_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.subjects
ADD CONSTRAINT fk_subject_level_id FOREIGN KEY (level_id) REFERENCES public.levels(id) ON DELETE CASCADE;
--
-- Name: teachers fk_teacher_level_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.teachers
ADD CONSTRAINT fk_teacher_level_id FOREIGN KEY (level_id) REFERENCES public.levels(id);
--
-- Name: teachers fk_teacher_person_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.teachers
ADD CONSTRAINT fk_teacher_person_id FOREIGN KEY (person_id) REFERENCES public.persons(id);
--
-- Name: teacher_subjects fk_teacher_subjects_subject_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.teacher_subjects
ADD CONSTRAINT fk_teacher_subjects_subject_id FOREIGN KEY (subject_id) REFERENCES public.subjects(id) ON DELETE SET NULL;
--
-- Name: teacher_subjects fk_teacher_subjects_teacher_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.teacher_subjects
ADD CONSTRAINT fk_teacher_subjects_teacher_id FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;
--
-- Name: users fk_user_person_id; Type: FK CONSTRAINT; Schema: public; Owner: root
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT fk_user_person_id FOREIGN KEY (person_id) REFERENCES public.persons(id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--