-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbhw.sql
524 lines (382 loc) · 12.5 KB
/
dbhw.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
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.9 (Ubuntu 12.9-0ubuntu0.20.04.1)
-- Dumped by pg_dump version 12.9 (Ubuntu 12.9-0ubuntu0.20.04.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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: country; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.country (
cname character varying(50) NOT NULL,
population bigint NOT NULL
);
--
-- Name: discover; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.discover (
cname character varying(50) NOT NULL,
disease_code character varying(50) NOT NULL,
first_enc_date date NOT NULL
);
--
-- Name: disease; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.disease (
id integer NOT NULL,
disease_code character varying(50) NOT NULL,
pathogen character varying(20) NOT NULL,
description character varying(140) NOT NULL
);
--
-- Name: diseasetype; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.diseasetype (
id integer NOT NULL,
description character varying(140) NOT NULL
);
--
-- Name: doctor; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.doctor (
email character varying(60) NOT NULL,
degree character varying(20) NOT NULL
);
--
-- Name: publicservant; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.publicservant (
email character varying(60) NOT NULL,
department character varying(50) NOT NULL
);
--
-- Name: record; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.record (
email character varying(60) NOT NULL,
cname character varying(50) NOT NULL,
disease_code character varying(50) NOT NULL,
total_deaths integer NOT NULL,
total_patients integer NOT NULL,
id integer NOT NULL
);
--
-- Name: record_id_seq; Type: SEQUENCE; Schema: public; Owner: madara
--
CREATE SEQUENCE public.record_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: record_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: madara
--
ALTER SEQUENCE public.record_id_seq OWNED BY public.record.id;
--
-- Name: specialize; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.specialize (
id integer NOT NULL,
email character varying(60) NOT NULL,
index integer NOT NULL
);
--
-- Name: specialize_index_seq; Type: SEQUENCE; Schema: public; Owner: madara
--
CREATE SEQUENCE public.specialize_index_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: specialize_index_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: madara
--
ALTER SEQUENCE public.specialize_index_seq OWNED BY public.specialize.index;
--
-- Name: users; Type: TABLE; Schema: public; Owner: madara
--
CREATE TABLE public.users (
email character varying(60) NOT NULL,
name character varying(30) NOT NULL,
surname character varying(40) NOT NULL,
salary integer NOT NULL,
phone character varying(20) NOT NULL,
cname character varying(50) NOT NULL
);
--
-- Name: record id; Type: DEFAULT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.record ALTER COLUMN id SET DEFAULT nextval('public.record_id_seq'::regclass);
--
-- Name: specialize index; Type: DEFAULT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.specialize ALTER COLUMN index SET DEFAULT nextval('public.specialize_index_seq'::regclass);
--
-- Data for Name: country; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.country (cname, population) FROM stdin;
Kazakhstan 18000000
Russia 120000000
USA 150000000
China 1400000000
Germany 50000000
Ukraine 40000000
Kosovo 5000000
Italy 25000000
Norway 14000000
Mexico 40000000
\.
--
-- Data for Name: discover; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.discover (cname, disease_code, first_enc_date) FROM stdin;
China danger 2019-11-03
Italy biohazard 1765-04-28
Kosovo rare 1999-12-15
Norway danger 1901-04-25
China covid-19 2019-11-05
USA parcinson 1817-05-25
Germany depression 1895-08-25
Russia syphilis 1876-04-12
USA diphtheria 1985-08-01
Kazakhstan diphtheria 1976-01-15
\.
--
-- Data for Name: disease; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.disease (id, disease_code, pathogen, description) FROM stdin;
1 danger virus causes death
4 rare fungus rare countries
1 biohazard parasite lethal
1 covid-19 virus caused by the SARS-CoV-2 virus
5 tuberculesis virus lung disease
6 cancer carcinoma cell disease
7 trojan bug software disease
8 humorist clown type of person
9 parcinson nervous brain damage
10 depression vitamins lack of vitamins
2 diphtheria bacteria serious infection
3 syphilis bacteria sexually transmitted disease
\.
--
-- Data for Name: diseasetype; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.diseasetype (id, description) FROM stdin;
1 infectious
2 hereditary
3 deficiency
4 physiological
5 virology
6 oncology
7 malware
8 ridiculous
9 tremorus
10 psychological
\.
--
-- Data for Name: doctor; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.doctor (email, degree) FROM stdin;
\.
--
-- Data for Name: publicservant; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.publicservant (email, department) FROM stdin;
[email protected] Dept1
[email protected] Dept2
[email protected] Dept2
[email protected] Dept3
[email protected] Dept1
[email protected] Dept3
\.
--
-- Data for Name: record; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.record (email, cname, disease_code, total_deaths, total_patients, id) FROM stdin;
[email protected] Germany covid-19 150000 855000 6
[email protected] Russia tuberculesis 14000 86000 9
[email protected] Italy covid-19 45600 245000 12
[email protected] Kazakhstan tuberculesis 55 1087 14
[email protected] USA parcinson 250000 1350000 16
[email protected] Kazakhstan depression 12000 165000 17
[email protected] Germany cancer 560000 2540000 18
[email protected] Italy covid-19 125545 656584 20
[email protected] Italy tuberculesis 1200 250000 21
[email protected] Norway syphilis 1000 15600 22
[email protected] China covid-19 250000 4500000 4
[email protected] Kazakhstan covid-19 10000 120000 3
[email protected] Russia syphilis 10 1000000 15
[email protected] Mexico covid-19 25000 1012800 8
[email protected] Italy covid-19 12300 2000000 5
[email protected] Germany trojan 100 10000 23
[email protected] Ukraine covid-19 12312 2423423 24
[email protected] Germany tuberculesis 234234 234234 25
\.
--
-- Data for Name: specialize; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.specialize (id, email, index) FROM stdin;
5 [email protected] 10
5 [email protected] 11
5 [email protected] 12
1 [email protected] 13
4 [email protected] 14
2 [email protected] 15
\.
--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: madara
--
COPY public.users (email, name, surname, salary, phone, cname) FROM stdin;
[email protected] Abay Kappassov 120000 87771112233 Kazakhstan
[email protected] Akerke Tolegen 150000 87776667788 Italy
[email protected] Akezhan Rakishev 200000 87777778899 Norway
[email protected] Akylzhan Sauranbay 85000 87773334455 Kosovo
[email protected] Arafat Bauyrzhanuly 180000 87778889900 Ukraine
[email protected] Aruzhan Aruzhan 230000 87770103445 Mexico
[email protected] Dilnaz Amanzholova 140000 87774445566 USA
[email protected] Dima Ivanov 174000 87071235487 Kosovo
[email protected] Madi Turysbek 100000 87076523252 Italy
[email protected] Madina Smetova 90000 87055623245 Kazakhstan
[email protected] Meruyert Karzhaubayeva 230000 87770001122 Norway
[email protected] Timur Rakhishov 195000 87772223344 Russia
\.
--
-- Name: record_id_seq; Type: SEQUENCE SET; Schema: public; Owner: madara
--
SELECT pg_catalog.setval('public.record_id_seq', 25, true);
--
-- Name: specialize_index_seq; Type: SEQUENCE SET; Schema: public; Owner: madara
--
SELECT pg_catalog.setval('public.specialize_index_seq', 15, true);
--
-- Name: discover Discover_pkey; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.discover
ADD CONSTRAINT "Discover_pkey" PRIMARY KEY (cname, disease_code);
--
-- Name: diseasetype DiseaseType_pkey; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.diseasetype
ADD CONSTRAINT "DiseaseType_pkey" PRIMARY KEY (id);
--
-- Name: doctor Doctor_pkey; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.doctor
ADD CONSTRAINT "Doctor_pkey" PRIMARY KEY (email);
--
-- Name: publicservant PublicServant_pkey; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.publicservant
ADD CONSTRAINT "PublicServant_pkey" PRIMARY KEY (email);
--
-- Name: users Users_pkey; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT "Users_pkey" PRIMARY KEY (email);
--
-- Name: country cname; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.country
ADD CONSTRAINT cname PRIMARY KEY (cname);
--
-- Name: disease disease_code; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.disease
ADD CONSTRAINT disease_code PRIMARY KEY (disease_code);
--
-- Name: record record_pkey; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.record
ADD CONSTRAINT record_pkey PRIMARY KEY (email, cname, disease_code, id);
--
-- Name: specialize spec_pkey; Type: CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.specialize
ADD CONSTRAINT spec_pkey PRIMARY KEY (id, email, index);
--
-- Name: discover cname; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.discover
ADD CONSTRAINT cname FOREIGN KEY (cname) REFERENCES public.country(cname);
--
-- Name: users cname; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT cname FOREIGN KEY (cname) REFERENCES public.country(cname);
--
-- Name: record cname; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.record
ADD CONSTRAINT cname FOREIGN KEY (cname) REFERENCES public.country(cname);
--
-- Name: discover disease_code; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.discover
ADD CONSTRAINT disease_code FOREIGN KEY (disease_code) REFERENCES public.disease(disease_code) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- Name: record disease_code; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.record
ADD CONSTRAINT disease_code FOREIGN KEY (disease_code) REFERENCES public.disease(disease_code) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- Name: publicservant email; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.publicservant
ADD CONSTRAINT email FOREIGN KEY (email) REFERENCES public.users(email) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- Name: doctor email; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.doctor
ADD CONSTRAINT email FOREIGN KEY (email) REFERENCES public.users(email) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- Name: specialize email; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.specialize
ADD CONSTRAINT email FOREIGN KEY (email) REFERENCES public.doctor(email) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- Name: record email; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.record
ADD CONSTRAINT email FOREIGN KEY (email) REFERENCES public.publicservant(email) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
--
-- Name: disease id; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.disease
ADD CONSTRAINT id FOREIGN KEY (id) REFERENCES public.diseasetype(id);
--
-- Name: specialize id; Type: FK CONSTRAINT; Schema: public; Owner: madara
--
ALTER TABLE ONLY public.specialize
ADD CONSTRAINT id FOREIGN KEY (id) REFERENCES public.diseasetype(id);
--
-- PostgreSQL database dump complete
--