-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_project.sql
More file actions
99 lines (93 loc) · 3.18 KB
/
Copy pathstudent_project.sql
File metadata and controls
99 lines (93 loc) · 3.18 KB
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
DROP TABLE IF EXISTS jc_student_child;
DROP TABLE IF EXISTS jc_student_order;
DROP TABLE IF EXISTS jc_passport_office;
DROP TABLE IF EXISTS jc_register_office;
DROP TABLE IF EXISTS jc_country_struct;
DROP TABLE IF EXISTS jc_street;
CREATE TABlE jc_street
(
street_code integer not null,
street_name varchar(300),
PRIMARY KEY (street_code)
);
CREATE TABLE jc_country_struct
(
area_id char(12) not null,
area_name varchar(200),
PRIMARY KEY (area_id)
);
CREATE TABLE jc_passport_office
(
p_office_id integer not null,
p_office_area_id char(12) not null,
p_office_name varchar(200),
PRIMARY KEY (p_office_id),
FOREIGN KEY (p_office_area_id) REFERENCES jc_country_struct(area_id) ON DELETE RESTRICT
);
CREATE TABLE jc_register_office
(
r_office_id integer not null,
r_office_area_id char(12) not null,
r_office_name varchar(200),
PRIMARY KEY (r_office_id),
FOREIGN KEY (r_office_area_id) REFERENCES jc_country_struct(area_id) ON DELETE RESTRICT
);
CREATE TABLE jc_student_order
(
student_order_id SERIAL,
student_order_status int not null,
student_order_date timestamp not null,
h_sur_name varchar(100) not null,
h_given_name varchar(100) not null,
h_patronymic varchar(100) not null,
h_date_of_birth date not null,
h_passport_seria varchar(10) not null,
h_passport_number varchar(10) not null,
h_passport_date date not null,
h_passport_office_id integer not null,
h_post_index varchar(10),
h_street_code integer not null,
h_building varchar(10) not null,
h_extension varchar(10),
h_apartment varchar(10),
w_sur_name varchar(100) not null,
w_given_name varchar(100) not null,
w_patronymic varchar(100) not null,
w_date_of_birth date not null,
w_passport_seria varchar(10) not null,
w_passport_number varchar(10) not null,
w_passport_date date not null,
w_passport_office_id integer not null,
w_post_index varchar(10),
w_street_code integer not null,
w_building varchar(10) not null,
w_extension varchar(10),
w_apartment varchar(10),
certificate_id varchar(20) not null,
register_office_id integer not null,
marriage_date date not null,
PRIMARY KEY (student_order_id),
FOREIGN KEY (h_street_code) REFERENCES jc_street(street_code) ON DELETE RESTRICT,
FOREIGN KEY (w_street_code) REFERENCES jc_street(street_code) ON DELETE RESTRICT,
FOREIGN KEY (register_office_id) REFERENCES jc_register_office(r_office_id) ON DELETE RESTRICT
);
CREATE TABLE jc_student_child
(
student_child_id SERIAL,
student_order_id integer not null,
c_sur_name varchar(100) not null,
c_given_name varchar(100) not null,
c_patronymic varchar(100) not null,
c_date_of_birth date not null,
c_sertificate_number varchar(10) not null,
c_sertificate_date date not null,
c_register_office_id integer not null,
c_post_index varchar(10),
c_street_code integer not null,
c_building varchar(10) not null,
c_extension varchar(10),
c_apartment varchar(10),
PRIMARY KEY (student_child_id),
FOREIGN KEY (c_street_code) REFERENCES jc_street(street_code) ON DELETE RESTRICT,
FOREIGN KEY (c_register_office_id) REFERENCES jc_register_office(r_office_id) ON DELETE RESTRICT
);