· 5 years ago · Nov 18, 2020, 02:12 PM
1/*==============================================================*/
2/* DBMS name: MySQL 5.0 */
3/* Created on: 18.11.2020 14:34:57 */
4/*==============================================================*/
5
6
7drop table if exists Cakalna_vrsta;
8
9drop table if exists Diagnoza;
10
11drop table if exists Diagnoza_pacient;
12
13drop table if exists Izvid_preizkave;
14
15drop table if exists Kraj;
16
17drop table if exists Laboratorijska_preiskava;
18
19drop table if exists Moski;
20
21drop table if exists Naslov;
22
23drop table if exists Obravnava;
24
25drop table if exists Oddelek;
26
27drop table if exists Pacient;
28
29drop table if exists Samoplacnik;
30
31drop table if exists Zenska;
32
33/*==============================================================*/
34/* Table: "Cakalna vrsta" */
35/*==============================================================*/
36create table Cakalna_vrsta
37(
38 st_obravnave int not null,
39 st_oddelek int not null,
40 vrsta_datum_cas_vpisa datetime,
41 vrsta_predviden_datum_cas_sprejema datetime,
42 primary key (st_obravnave, st_oddelek)
43);
44
45/*==============================================================*/
46/* Table: Diagnoza */
47/*==============================================================*/
48create table Diagnoza
49(
50 id_diagnoze int not null,
51 ICD_slo_klasifikacija varchar(50),
52 ICD_ang_klasifikacija varchar(50),
53 ICD_medn_klasifikacija varchar(50),
54 primary key (id diagnoze)
55);
56
57/*==============================================================*/
58/* Table: "Diagnoza pacient" */
59/*==============================================================*/
60create table Diagnoza_pacient
61(
62 KZZ_id int not null,
63 id_diagnoze int not null,
64 st_diagnoze int not null,
65 primary key (KZZ_id, id diagnoze, st_diagnoze)
66);
67
68/*==============================================================*/
69/* Table: "Izvid preizkave" */
70/*==============================================================*/
71create table Izvid_preizkave
72(
73 cas_preiskave time,
74 rezultat_preiskave float(5),
75 st_izvida int not null,
76 id_samoplacnika int,
77 preiskava_id int not null,
78 st_obravnave int,
79 primary key (st_izvida)
80);
81
82/*==============================================================*/
83/* Table: Kraj */
84/*==============================================================*/
85create table Kraj
86(
87 postna_stevilka_id int not null,
88 kraj_ime varchar(20),
89 primary key (postna_stevilka_id)
90);
91
92/*==============================================================*/
93/* Table: "Laboratorijska preiskava" */
94/*==============================================================*/
95create table Laboratorijska_preiskava
96(
97 preiskava_id int not null,
98 preiskava_ime varchar(20),
99 preiskava_min_dopustni_interval float(5),
100 preiskava_max_dopustni_interval float(5),
101 preiskava_cena_samoplacniki float(10),
102 preiskava_datum_cas datetime,
103 primary key (preiskava_id)
104);
105
106/*==============================================================*/
107/* Table: Moski */
108/*==============================================================*/
109create table Moski
110(
111 preiskava_id int not null,
112 referencna_vrednost_min float(4),
113 referencna_vrednost_max float(4),
114 primary key (preiskava_id)
115);
116
117/*==============================================================*/
118/* Table: Naslov */
119/*==============================================================*/
120create table Naslov
121(
122 naslov_id int not null,
123 postna_stevilka_id int not null,
124 naslov_ulica varchar(20),
125 naslov_hisna_stevilka varchar(5),
126 primary key (naslov_id)
127);
128
129/*==============================================================*/
130/* Table: Obravnava */
131/*==============================================================*/
132create table Obravnava
133(
134 st_obravnave int not null,
135 KZZ_id int not null,
136 primary key (st_obravnave)
137);
138
139/*==============================================================*/
140/* Table: Oddelek */
141/*==============================================================*/
142create table Oddelek
143(
144 st_oddelek int not null,
145 oddelek_ime varchar(50),
146 primary key (st_oddelek)
147);
148
149/*==============================================================*/
150/* Table: Pacient */
151/*==============================================================*/
152create table Pacient
153(
154 KZZ_id int not null,
155 naslov_id int not null,
156 pacient_ime varchar(20),
157 pacient_priimek varchar(50),
158 pacient_datum_rojstva date,
159 pacient_spol char(1),
160 primary key (KZZ_id)
161);
162
163/*==============================================================*/
164/* Table: Samoplacnik */
165/*==============================================================*/
166create table Samoplacnik
167(
168 id_samoplacnika int not null,
169 primary key (id_samoplacnika)
170);
171
172/*==============================================================*/
173/* Table: Zenska */
174/*==============================================================*/
175create table Zenska
176(
177 preiskava_id int not null,
178 referencna_vrednost_min float(4),
179 referencna_vrednost_max float(4),
180 primary key (preiskava_id)
181);
182
183alter table Cakalna_vrsta add constraint FK_je umescen foreign key (st_obravnave)
184 references Obravnava (st_obravnave) on delete restrict on update restrict;
185
186alter table Cakalna_vrsta add constraint FK_pripada_oddelku foreign key (st_oddelek)
187 references Oddelek (st_oddelek) on delete restrict on update restrict;
188
189alter table Diagnoza_pacient add constraint FK_ima foreign key (KZZ_id)
190 references Pacient (KZZ_id) on delete restrict on update restrict;
191
192alter table Diagnoza_pacient add constraint FK_je_definirana_z foreign key (id_diagnoze)
193 references Diagnoza (id_diagnoze) on delete restrict on update restrict;
194
195alter table Izvid_preizkave add constraint FK_definira foreign key (preiskava_id)
196 references Laboratorijska_preiskava (preiskava_id) on delete restrict on update restrict;
197
198alter table Izvid_preizkave add constraint FK_naroci foreign key (id_samoplacnika)
199 references Samoplacnik (id_samoplaènika) on delete restrict on update restrict;
200
201alter table Izvid_preizkave add constraint FK_pripada_obravnavi foreign key (st_obravnave)
202 references Obravnava (st_obravnave) on delete restrict on update restrict;
203
204alter table Moski add constraint FK_Referencna_vrednost foreign key (preiskava_id)
205 references Laboratorijska_preiskava (preiskava_id) on delete restrict on update restrict;
206
207alter table Naslov add constraint FK_se_nahaja_v foreign key (postna_stevilka_id)
208 references Kraj (postna_stevilka_id) on delete restrict on update restrict;
209
210alter table Obravnava add constraint FK_je_dodeljena foreign key (KZZ_id)
211 references Pacient (KZZ_id) on delete restrict on update restrict;
212
213alter table Pacient add constraint FK_pripada foreign key (naslov_id)
214 references Naslov (naslov_id) on delete restrict on update restrict;
215
216alter table Zenska add constraint FK_Referencna_vrednost foreign key (preiskava_id)
217 references Laboratorijska_preiskava (preiskava_id) on delete restrict on update restrict;
218
219