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
| CREATE TABLE t_student
(
u_id serial NOT NULL,
s_idstudent varchar(20),
s_civ varchar(20),
s_name varchar(200),
s_firstname varchar(200),
...
CONSTRAINT t_student_pkey PRIMARY KEY (u_id),
CONSTRAINT t_student_s_idstudent_key UNIQUE (s_idstudent)
)
CREATE TABLE t_period
(
per_id serial NOT NULL,
o_id int4,
tri_id int4 NOT NULL,
y_id int4 NOT NULL,
u_id int4 NOT NULL,
p_uid int4 NOT NULL,
per_current bool,
...
CONSTRAINT t_period_pkey PRIMARY KEY (per_id),
CONSTRAINT t_period_o_id_fkey FOREIGN KEY (o_id)
REFERENCES t_option (o_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT t_period_p_uid_fkey FOREIGN KEY (p_uid)
REFERENCES t_promo (p_uid) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT t_period_tri_id_fkey FOREIGN KEY (tri_id)
REFERENCES t_trimester (tri_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT t_period_u_id_fkey FOREIGN KEY (u_id)
REFERENCES t_user (u_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT t_period_y_id_fkey FOREIGN KEY (y_id)
REFERENCES t_year (y_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT periodkey UNIQUE (o_id, tri_id, y_id, u_id, p_uid)
)
CREATE TABLE t_trimester
(
tri_id serial NOT NULL,
tri_name varchar(20),
tri_describe varchar(50),
p_uid int4,
CONSTRAINT t_trimester_pkey PRIMARY KEY (tri_id),
CONSTRAINT t_trimester_p_uid_fkey FOREIGN KEY (p_uid)
REFERENCES t_promo (p_uid) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT
)
CREATE TABLE coconut.t_admissionfolder
(
a_id serial NOT NULL,
per_id int4 NOT NULL,
a_registerdate date,
a_comment text,
...
CONSTRAINT t_admissionfolder_pkey PRIMARY KEY (a_id),
CONSTRAINT fkey_formula FOREIGN KEY (f_id)
REFERENCES coconut.t_formula (f_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT t_admissionfolder_is_id_fkey FOREIGN KEY (is_id)
REFERENCES coconut.t_informativesource (is_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT
) |
Partager