-
Notifications
You must be signed in to change notification settings - Fork 6
/
PostgreDatabaseSQL
296 lines (237 loc) · 7.47 KB
/
PostgreDatabaseSQL
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
-- This script was generated by a beta version of the ERD tool in pgAdmin 4.
-- Please log an issue at https://redmine.postgresql.org/projects/pgadmin4/issues/new if you find any bugs, including reproduction steps.
BEGIN;
CREATE TABLE public.activation_panel_for_system_user
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
detail character varying(200),
activation_date timestamp without time zone,
is_approved boolean,
system_user integer,
job_id integer,
PRIMARY KEY (id)
);
CREATE TABLE public.attended_schools
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
school_id integer NOT NULL,
"startingDateOfUniversity" date NOT NULL,
"graduationDateOfUniversity" date,
job_seeker_id integer,
graduation_date_of_university timestamp without time zone,
starting_date_of_university timestamp without time zone,
PRIMARY KEY (id)
);
CREATE TABLE public.cities
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
city_name character varying(200) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.department
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
department_name character varying NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.departments
(
id integer NOT NULL,
department_name character varying(255),
PRIMARY KEY (id)
);
CREATE TABLE public.employers
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 32767 CACHE 1 ),
userid integer,
companyname character varying(50),
website character varying(100),
phonenumber character varying(15),
PRIMARY KEY (id)
);
CREATE TABLE public.images
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
job_seeker_id integer NOT NULL,
image_title character varying(100) NOT NULL,
image character varying(500) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.job_positions
(
id integer NOT NULL,
position_name character varying(50),
PRIMARY KEY (id)
);
CREATE TABLE public.job_seekers
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 32767 CACHE 1 ),
userid integer,
firstname character varying(50),
lastname character varying(50),
birthdate integer,
nationalityid bigint,
github_account character varying(255),
info_about_job_seeker character varying(255),
linkedin_account character varying(255),
job_position_id integer,
PRIMARY KEY (id)
);
CREATE TABLE public.jobs
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
general_position_id integer NOT NULL,
description character varying(3400) NOT NULL,
city_id integer NOT NULL,
min_salary integer NOT NULL,
max_salary integer NOT NULL,
number_of_empty_positions integer NOT NULL,
is_active boolean NOT NULL,
deadline date NOT NULL,
created_date date NOT NULL,
employer_id integer NOT NULL,
work_place_id integer NOT NULL,
work_time_id integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.known_languages
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
language_level_id integer NOT NULL,
language_name character varying NOT NULL,
job_seeker_id integer,
PRIMARY KEY (id)
);
CREATE TABLE public.language_levels
(
id integer NOT NULL,
level_description character varying(200) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.schools
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
school_name character varying(200) NOT NULL,
department_id integer,
PRIMARY KEY (id)
);
CREATE TABLE public.system_users
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 32767 CACHE 1 ),
userid integer,
role character varying(255),
PRIMARY KEY (id)
);
CREATE TABLE public.users
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 32767 CACHE 1 ),
isactivated boolean NOT NULL,
status boolean NOT NULL,
email character varying(100),
createddate date,
password character varying(255),
PRIMARY KEY (id)
);
CREATE TABLE public.work_experiences
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
position_id integer NOT NULL,
workplace_name character varying NOT NULL,
starting_date date NOT NULL,
quit_date date,
job_seeker_id integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.work_place
(
id integer NOT NULL,
work_place_name character varying(255),
PRIMARY KEY (id)
);
CREATE TABLE public.work_time
(
id integer NOT NULL,
work_time_name character varying(255),
PRIMARY KEY (id)
);
ALTER TABLE public.activation_panel_for_system_user
ADD FOREIGN KEY (job_id)
REFERENCES public.jobs (id)
NOT VALID;
ALTER TABLE public.activation_panel_for_system_user
ADD FOREIGN KEY (system_user)
REFERENCES public.system_users (id)
NOT VALID;
ALTER TABLE public.attended_schools
ADD FOREIGN KEY (job_seeker_id)
REFERENCES public.job_seekers (id)
NOT VALID;
ALTER TABLE public.attended_schools
ADD FOREIGN KEY (school_id)
REFERENCES public.schools (id)
NOT VALID;
ALTER TABLE public.departments
ADD FOREIGN KEY (id)
REFERENCES public.schools (id)
NOT VALID;
ALTER TABLE public.employers
ADD FOREIGN KEY (userid)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.images
ADD FOREIGN KEY (job_seeker_id)
REFERENCES public.job_seekers (id)
NOT VALID;
ALTER TABLE public.job_seekers
ADD FOREIGN KEY (job_position_id)
REFERENCES public.job_positions (id)
NOT VALID;
ALTER TABLE public.job_seekers
ADD FOREIGN KEY (userid)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.jobs
ADD FOREIGN KEY (city_id)
REFERENCES public.cities (id)
NOT VALID;
ALTER TABLE public.jobs
ADD FOREIGN KEY (employer_id)
REFERENCES public.employers (id)
NOT VALID;
ALTER TABLE public.jobs
ADD FOREIGN KEY (work_time_id)
REFERENCES public.work_time (id)
NOT VALID;
ALTER TABLE public.jobs
ADD FOREIGN KEY (work_place_id)
REFERENCES public.work_place (id)
NOT VALID;
ALTER TABLE public.jobs
ADD FOREIGN KEY (general_position_id)
REFERENCES public.job_positions (id)
NOT VALID;
ALTER TABLE public.known_languages
ADD FOREIGN KEY (job_seeker_id)
REFERENCES public.job_seekers (id)
NOT VALID;
ALTER TABLE public.known_languages
ADD FOREIGN KEY (language_level_id)
REFERENCES public.language_levels (id)
NOT VALID;
ALTER TABLE public.schools
ADD FOREIGN KEY (department_id)
REFERENCES public.department (id)
NOT VALID;
ALTER TABLE public.system_users
ADD FOREIGN KEY (userid)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.work_experiences
ADD FOREIGN KEY (job_seeker_id)
REFERENCES public.job_seekers (id)
NOT VALID;
ALTER TABLE public.work_experiences
ADD FOREIGN KEY (position_id)
REFERENCES public.job_positions (id)
NOT VALID;
END;