forked from francoisjacquet/rosariosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rosariosis.sql
5795 lines (3884 loc) · 158 KB
/
rosariosis.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
997
998
999
1000
--
-- PostgreSQL database dump
--
-- Note: Uncheck "Paginate results" when importing with phpPgAdmin
--
SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;
-- Fix #102 error language "plpgsql" does not exist
-- http://timmurphy.org/2011/08/27/create-language-if-it-doesnt-exist-in-postgresql/
--
-- Name: create_language_plpgsql(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION create_language_plpgsql()
RETURNS BOOLEAN AS $$
CREATE LANGUAGE plpgsql;
SELECT TRUE;
$$ LANGUAGE SQL;
SELECT CASE WHEN NOT
(
SELECT TRUE AS exists
FROM pg_language
WHERE lanname = 'plpgsql'
UNION
SELECT FALSE AS exists
ORDER BY exists DESC
LIMIT 1
)
THEN
create_language_plpgsql()
ELSE
FALSE
END AS plpgsql_created;
DROP FUNCTION create_language_plpgsql();
--modif Francois: fix calc_cum_cr_gpa()
--
-- Name: calc_cum_cr_gpa(character varying, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION calc_cum_cr_gpa(character varying, integer) RETURNS integer
LANGUAGE plpgsql
AS $_$DECLARE
mp_id ALIAS for $1;
s_id ALIAS for $2;
mpinfo marking_periods%ROWTYPE;
s student_mp_stats%ROWTYPE;
BEGIN
UPDATE student_mp_stats
SET cum_cr_weighted_factor = cr_weighted_factors/cr_credits,
cum_cr_unweighted_factor = cr_unweighted_factors/cr_credits
WHERE student_mp_stats.student_id = s_id and cast(student_mp_stats.marking_period_id as text) = mp_id;
RETURN 1;
END;
$_$;
--modif Francois: fix calc_cum_gpa()
--
-- Name: calc_cum_gpa(character varying, integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION calc_cum_gpa(character varying, integer) RETURNS integer
LANGUAGE plpgsql
AS $_$DECLARE
mp_id ALIAS for $1;
s_id ALIAS for $2;
mpinfo marking_periods%ROWTYPE;
s student_mp_stats%ROWTYPE;
BEGIN
UPDATE student_mp_stats
SET cum_weighted_factor = sum_weighted_factors/gp_credits,
cum_unweighted_factor = sum_unweighted_factors/gp_credits
WHERE student_mp_stats.student_id = s_id and cast(student_mp_stats.marking_period_id as text) = mp_id;
RETURN 1;
END;
$_$;
--modif Francois: fix calc_cum_gpa_mp()
--
-- Name: calc_cum_gpa_mp(character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE OR REPLACE FUNCTION calc_cum_gpa_mp(character varying) RETURNS integer
AS $_$DECLARE
mp_id ALIAS for $1;
mpinfo marking_periods%ROWTYPE;
s student_mp_stats%ROWTYPE;
BEGIN
FOR s in select student_id from student_mp_stats where cast(marking_period_id as text) = mp_id LOOP
PERFORM calc_cum_gpa(mp_id, s.student_id);
PERFORM calc_cum_cr_gpa(mp_id, s.student_id);
END LOOP;
RETURN 1;
END;
$_$
LANGUAGE plpgsql;
--modif Francois: fix calc_gpa_mp() + credit()
--
-- Name: calc_gpa_mp(integer, character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE OR REPLACE FUNCTION calc_gpa_mp(integer, character varying) RETURNS integer
AS $_$
DECLARE
s_id ALIAS for $1;
mp_id ALIAS for $2;
oldrec student_mp_stats%ROWTYPE;
BEGIN
SELECT * INTO oldrec FROM student_mp_stats WHERE student_id = s_id and cast(marking_period_id as text) = mp_id;
IF FOUND THEN
UPDATE STUDENT_MP_STATS SET
sum_weighted_factors = rcg.sum_weighted_factors,
sum_unweighted_factors = rcg.sum_unweighted_factors,
cr_weighted_factors = rcg.cr_weighted,
cr_unweighted_factors = rcg.cr_unweighted,
gp_credits = rcg.gp_credits,
cr_credits = rcg.cr_credits
FROM (
select
sum(weighted_gp*credit_attempted/gp_scale) as sum_weighted_factors,
sum(unweighted_gp*credit_attempted/gp_scale) as sum_unweighted_factors,
sum(credit_attempted) as gp_credits,
sum( case when class_rank = 'Y' THEN weighted_gp*credit_attempted/gp_scale END ) as cr_weighted,
sum( case when class_rank = 'Y' THEN unweighted_gp*credit_attempted/gp_scale END ) as cr_unweighted,
sum( case when class_rank = 'Y' THEN credit_attempted END) as cr_credits
from student_report_card_grades where student_id = s_id
and cast(marking_period_id as text) = mp_id
and not gp_scale = 0 group by student_id, marking_period_id
) as rcg
WHERE student_id = s_id and cast(marking_period_id as text) = mp_id;
RETURN 1;
ELSE
INSERT INTO STUDENT_MP_STATS (student_id, marking_period_id, sum_weighted_factors, sum_unweighted_factors, grade_level_short, cr_weighted_factors, cr_unweighted_factors, gp_credits, cr_credits)
select
srcg.student_id, (srcg.marking_period_id::text)::int,
sum(weighted_gp*credit_attempted/gp_scale) as sum_weighted_factors,
sum(unweighted_gp*credit_attempted/gp_scale) as sum_unweighted_factors,
eg.short_name,
sum( case when class_rank = 'Y' THEN weighted_gp*credit_attempted/gp_scale END ) as cr_weighted,
sum( case when class_rank = 'Y' THEN unweighted_gp*credit_attempted/gp_scale END ) as cr_unweighted,
sum(credit_attempted) as gp_credits,
sum(case when class_rank = 'Y' THEN credit_attempted END) as cr_credits
from student_report_card_grades srcg join marking_periods mp on (cast(mp.marking_period_id as text) = srcg.marking_period_id) left outer join enroll_grade eg on (eg.student_id = srcg.student_id and eg.syear = mp.syear and eg.school_id = mp.school_id)
where srcg.student_id = s_id and cast(srcg.marking_period_id as text) = mp_id and not srcg.gp_scale = 0
group by srcg.student_id, srcg.marking_period_id, eg.short_name;
END IF;
RETURN 0;
END
$_$
LANGUAGE plpgsql;
--
-- Name: credit(integer, character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE OR REPLACE FUNCTION credit(integer, character varying) RETURNS numeric
AS $_$
DECLARE
course_detail RECORD;
mp_detail RECORD;
values RECORD;
BEGIN
select * into course_detail from course_periods where course_period_id = $1;
select * into mp_detail from marking_periods where cast(marking_period_id as text) = $2;
IF course_detail.marking_period_id = mp_detail.marking_period_id THEN
return course_detail.credits;
ELSIF course_detail.mp = 'FY' AND mp_detail.mp_type = 'semester' THEN
select into values count(*) as mp_count from marking_periods where parent_id = course_detail.marking_period_id group by parent_id;
ELSIF course_detail.mp = 'FY' and mp_detail.mp_type = 'quarter' THEN
select into values count(*) as mp_count from marking_periods where grandparent_id = course_detail.marking_period_id group by grandparent_id;
ELSIF course_detail.mp = 'SEM' and mp_detail.mp_type = 'quarter' THEN
select into values count(*) as mp_count from marking_periods where parent_id = course_detail.marking_period_id group by parent_id;
ELSE
return course_detail.credits;
END IF;
IF values.mp_count > 0 THEN
return course_detail.credits/values.mp_count;
ELSE
return course_detail.credits;
END IF;
END$_$
LANGUAGE plpgsql;
--modif Francois: fix set_class_rank_mp()
--
-- Name: set_class_rank_mp(character varying); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE OR REPLACE FUNCTION set_class_rank_mp(character varying) RETURNS integer
AS $_$
DECLARE
mp_id alias for $1;
BEGIN
update student_mp_stats set cum_rank = rank.rank, class_size = rank.class_size from
(
select
mp.syear, mp.marking_period_id, sgm.student_id, se.grade_id, sgm.cum_cr_weighted_factor
,
(select count(*)+1
from student_mp_stats sgm3
where sgm3.cum_cr_weighted_factor > sgm.cum_cr_weighted_factor
and sgm3.marking_period_id = mp.marking_period_id
and sgm3.student_id in (select distinct sgm2.student_id
from student_mp_stats sgm2, student_enrollment se2
where sgm2.student_id = se2.student_id
and sgm2.marking_period_id = mp.marking_period_id
and se2.grade_id = se.grade_id
and se2.syear = se.syear)
) as rank,
(select count(*)
from student_mp_stats sgm4
where
sgm4.marking_period_id = mp.marking_period_id
and sgm4.student_id in (select distinct sgm5.student_id
from student_mp_stats sgm5, student_enrollment se3
where sgm5.student_id = se3.student_id
and sgm5.marking_period_id = mp.marking_period_id
and se3.grade_id = se.grade_id
and se3.syear = se.syear)
) as class_size
from student_enrollment se, student_mp_stats sgm, marking_periods mp
where
se.student_id = sgm.student_id
and sgm.marking_period_id = mp.marking_period_id
and cast(mp.marking_period_id as text) = mp_id
and se.syear = mp.syear
and not sgm.cum_cr_weighted_factor is null
order by grade_id, rank ) as rank
where student_mp_stats.marking_period_id = rank.marking_period_id
and student_mp_stats.student_id = rank.student_id;
RETURN 1;
END;
$_$
LANGUAGE plpgsql;
--
-- Name: t_update_mp_stats(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION t_update_mp_stats() RETURNS "trigger"
AS $$
begin
IF tg_op = 'DELETE' THEN
perform calc_gpa_mp(OLD.student_id::int, OLD.marking_period_id::varchar);
ELSE
--IF tg_op = 'INSERT' THEN
--we need to do stuff here to gather other information since it's a new record.
--ELSE
--if report_card_grade_id changes, then we need to reset gp values
-- IF NOT NEW.report_card_grade_id = OLD.report_card_grade_id THEN
--
perform calc_gpa_mp(NEW.student_id::int, NEW.marking_period_id::varchar);
END IF;
return NULL;
end
$$
LANGUAGE plpgsql;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: accounting_incomes; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE accounting_incomes (
assigned_date date,
comments character varying(255),
id numeric,
title character varying(255),
amount numeric,
school_id numeric,
syear numeric
);
--
-- Name: accounting_incomes_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE accounting_incomes_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: accounting_incomes_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('accounting_incomes_seq', 1, false);
--
-- Name: accounting_salaries; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE accounting_salaries (
staff_id numeric NOT NULL,
assigned_date date,
due_date date,
comments character varying(255),
id numeric,
title character varying(255),
amount numeric,
school_id numeric,
syear numeric
);
--
-- Name: accounting_salaries_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE accounting_salaries_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: accounting_salaries_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('accounting_salaries_seq', 1, false);
--
-- Name: accounting_payments; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE accounting_payments (
id numeric NOT NULL,
syear numeric NOT NULL,
school_id numeric NOT NULL,
staff_id numeric,
amount numeric NOT NULL,
payment_date date,
comments character varying(255)
);
--
-- Name: accounting_payments_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE accounting_payments_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: accounting_payments_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('accounting_payments_seq', 1, false);
--
-- Name: address; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE address (
address_id numeric(10,0) NOT NULL,
house_no numeric(5,0),
fraction character varying(3),
letter character varying(2),
direction character varying(2),
street character varying(30),
apt character varying(5),
zipcode character varying(10),
plus4 character varying(4),
city character varying(60),
state character varying(10),
mail_street character varying(30),
mail_city character varying(60),
mail_state character varying(10),
mail_zipcode character varying(10),
address character varying(255),
mail_address character varying(255),
phone character varying(30)
);
--
-- Name: address_field_categories; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE address_field_categories (
id numeric NOT NULL,
title character varying(1000) NOT NULL,
sort_order numeric,
residence character(1),
mailing character(1),
bus character(1)
);
--
-- Name: address_field_categories_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE address_field_categories_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: address_field_categories_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('address_field_categories_seq', 1, false);
--
-- Name: address_fields; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE address_fields (
id numeric NOT NULL,
type character varying(10) NOT NULL,
title character varying(1000) NOT NULL,
sort_order numeric,
select_options character varying(10000),
category_id numeric,
required character varying(1),
default_selection character varying(255)
);
--
-- Name: address_fields_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE address_fields_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: address_fields_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('address_fields_seq', 1, true);
--
-- Name: address_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE address_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: address_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('address_seq', 1, true);
--
-- Name: attendance_calendar; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE attendance_calendar (
syear numeric(4,0) NOT NULL,
school_id numeric NOT NULL,
school_date date NOT NULL,
minutes numeric,
block character varying(10),
calendar_id numeric NOT NULL
);
--
-- Name: attendance_calendars; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE attendance_calendars (
school_id numeric,
title character varying(100),
syear numeric(4,0),
calendar_id numeric NOT NULL,
default_calendar character varying(1),
rollover_id numeric
);
--
-- Name: attendance_code_categories; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE attendance_code_categories (
id numeric,
syear numeric(4,0),
school_id numeric,
title character varying(255),
sort_order numeric,
rollover_id numeric
);
--
-- Name: attendance_code_categories_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE attendance_code_categories_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: attendance_code_categories_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('attendance_code_categories_seq', 1, false);
--
-- Name: attendance_codes; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE attendance_codes (
id numeric NOT NULL,
syear numeric(4,0),
school_id numeric,
title character varying(100),
short_name character varying(10),
type character varying(10),
state_code character varying(1),
default_code character varying(1),
table_name numeric,
sort_order numeric
);
--
-- Name: attendance_codes_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE attendance_codes_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: attendance_codes_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('attendance_codes_seq', 4, true);
--
-- Name: attendance_completed; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE attendance_completed (
staff_id numeric NOT NULL,
school_date date NOT NULL,
period_id numeric NOT NULL,
table_name numeric NOT NULL
);
--
-- Name: attendance_day; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE attendance_day (
student_id numeric NOT NULL,
school_date date NOT NULL,
minutes_present numeric,
state_value numeric(2,1),
syear numeric(4,0),
marking_period_id numeric,
comment character varying(255)
);
--
-- Name: attendance_period; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE attendance_period (
student_id numeric NOT NULL,
school_date date NOT NULL,
period_id numeric NOT NULL,
attendance_code numeric,
attendance_teacher_code numeric,
attendance_reason character varying(100),
admin character varying(1),
course_period_id numeric,
marking_period_id numeric,
comment character varying(100)
);
--
-- Name: billing_fees; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE billing_fees (
student_id numeric NOT NULL,
assigned_date date,
due_date date,
comments character varying(255),
id numeric,
title character varying(255),
amount numeric,
school_id numeric,
syear numeric,
waived_fee_id numeric,
old_id numeric
);
--
-- Name: billing_fees_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE billing_fees_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: billing_fees_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('billing_fees_seq', 1, false);
--
-- Name: billing_payments; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE billing_payments (
id numeric NOT NULL,
syear numeric NOT NULL,
school_id numeric NOT NULL,
student_id numeric NOT NULL,
amount numeric NOT NULL,
payment_date date,
comments character varying(255),
refunded_payment_id numeric,
lunch_payment character varying(1)
);
--
-- Name: billing_payments_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE billing_payments_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: billing_payments_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('billing_payments_seq', 1, false);
--
-- Name: calendar_events; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE calendar_events (
id numeric NOT NULL,
syear numeric(4,0),
school_id numeric,
school_date date,
title character varying(50),
description character varying(500)
);
--
-- Name: calendar_events_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE calendar_events_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: calendar_events_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('calendar_events_seq', 1, true);
--
-- Name: calendars_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE calendars_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: calendars_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('calendars_seq', 1, true);
--
-- Name: config; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE config (
school_id numeric NOT NULL,
title character varying(100),
config_value character varying(2550)
);
--
-- Name: course_periods; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE course_periods (
syear numeric(4,0) NOT NULL,
school_id numeric NOT NULL,
course_period_id numeric NOT NULL,
course_id numeric NOT NULL,
title character varying(255),
short_name character varying(25) NOT NULL,
mp character varying(3),
marking_period_id numeric,
teacher_id numeric NOT NULL,
room character varying(10),
total_seats numeric,
filled_seats numeric,
does_attendance character varying(255),
does_honor_roll character varying(1),
does_class_rank character varying(1),
gender_restriction character varying(1),
house_restriction character varying(1),
availability numeric,
parent_id numeric,
calendar_id numeric,
half_day character varying(1),
does_breakoff character varying(1),
rollover_id numeric,
grade_scale_id numeric,
credits numeric
);
--
-- Name: courses; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE courses (
syear numeric(4,0) NOT NULL,
course_id numeric NOT NULL,
subject_id numeric NOT NULL,
school_id numeric NOT NULL,
grade_level numeric,
title character varying(100) NOT NULL,
short_name character varying(25),
rollover_id numeric,
credit_hours numeric(6,2)
);
--
-- Name: course_details; Type: VIEW; Schema: public; Owner: rosariosis
--
CREATE VIEW course_details AS
SELECT cp.school_id, cp.syear, cp.marking_period_id, c.subject_id, cp.course_id, cp.course_period_id, cp.teacher_id, c.title AS course_title, cp.title AS cp_title, cp.grade_scale_id, cp.mp, cp.credits FROM course_periods cp, courses c WHERE (cp.course_id = c.course_id);
--
-- Name: course_period_school_periods; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE course_period_school_periods (
course_period_school_periods_id numeric NOT NULL,
course_period_id numeric NOT NULL,
period_id numeric NOT NULL,
days character varying(7)
);
--
-- Name: course_period_school_periods_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE course_period_school_periods_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: course_period_school_periods_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('course_period_school_periods_seq', 1, true);
--
-- Name: course_periods_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE course_periods_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: course_periods_seq; Type: SEQUENCE SET; Schema: public; Owner: rosariosis
--
SELECT pg_catalog.setval('course_periods_seq', 1, true);
--
-- Name: course_subjects; Type: TABLE; Schema: public; Owner: rosariosis; Tablespace:
--
CREATE TABLE course_subjects (
syear numeric(4,0),
school_id numeric,
subject_id numeric NOT NULL,
title character varying(100) NOT NULL,
short_name character varying(25),
sort_order numeric,
rollover_id numeric
);
--
-- Name: course_subjects_seq; Type: SEQUENCE; Schema: public; Owner: rosariosis
--
CREATE SEQUENCE course_subjects_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;