1 | drop table if exists LTel_Broj;
|
---|
2 | drop table if exists ITel_Broj;
|
---|
3 | drop table if exists Klasificira;
|
---|
4 | drop table if exists Napisal;
|
---|
5 | drop table if exists Rezervacija;
|
---|
6 | drop table if exists Pozajmica;
|
---|
7 | drop table if exists Dodava;
|
---|
8 | drop table if exists InstancaKniga;
|
---|
9 | drop table if exists Kategorija;
|
---|
10 | drop table if exists Ocena;
|
---|
11 | drop table if exists Avtor;
|
---|
12 | drop table if exists Knigi;
|
---|
13 | drop table if exists Izdavac;
|
---|
14 | drop table if exists Bibliotekar;
|
---|
15 | drop table if exists Clen;
|
---|
16 | drop table if exists Lugje;
|
---|
17 | drop table if exists Biblioteka;
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 | create table Biblioteka
|
---|
26 | (
|
---|
27 | bibliotekaID integer primary key not null,
|
---|
28 | bAdresa varchar (100) not null,
|
---|
29 | bIme varchar (100) not null
|
---|
30 | );
|
---|
31 |
|
---|
32 |
|
---|
33 | create table Lugje
|
---|
34 | (
|
---|
35 | lugjeID integer primary key not null,
|
---|
36 | ime varchar (100) not null,
|
---|
37 | prezime varchar (100) not null,
|
---|
38 | adresa varchar (100),
|
---|
39 | email varchar (100) not null
|
---|
40 | );
|
---|
41 |
|
---|
42 | create table Clen
|
---|
43 | (
|
---|
44 | clenskiBr integer not null references Lugje(lugjeID),
|
---|
45 | datumZaclenuvanje date not null,
|
---|
46 | passwordClen varchar (100) not null,
|
---|
47 | constraint pk_clen primary key(clenskiBr)
|
---|
48 | );
|
---|
49 |
|
---|
50 | create table Bibliotekar
|
---|
51 | (
|
---|
52 | bibliotekarID integer not null references Lugje(lugjeID),
|
---|
53 | bibliotekaID integer not null references Biblioteka(bibliotekaID),
|
---|
54 | constraint pk_bibliotekar primary key (bibliotekarID)
|
---|
55 | );
|
---|
56 |
|
---|
57 | create table LTel_Broj
|
---|
58 | (
|
---|
59 | lugjeID integer references Lugje(lugjeID),
|
---|
60 | lTel_Broj varchar (100) not null,
|
---|
61 | constraint pk_ltel_broj primary key(lugjeID, lTel_Broj)
|
---|
62 | );
|
---|
63 |
|
---|
64 |
|
---|
65 | create table Izdavac
|
---|
66 | (
|
---|
67 | izdavacID integer primary key not null,
|
---|
68 | iAdresa varchar (100),
|
---|
69 | iIme varchar (100) not null,
|
---|
70 | iEmail varchar (100) not null
|
---|
71 | );
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 | create table ITel_Broj
|
---|
78 | (
|
---|
79 | izdavacID integer not null references Izdavac(izdavacID),
|
---|
80 | lTel_Broj varchar (100) not null,
|
---|
81 | constraint pk_itel_broj primary key(izdavacID, lTel_Broj)
|
---|
82 | );
|
---|
83 |
|
---|
84 |
|
---|
85 | create table Knigi
|
---|
86 | (
|
---|
87 | knigaID integer primary key not null,
|
---|
88 | naslov varchar (100) not null,
|
---|
89 | kFormat varchar (100) not null,
|
---|
90 | kOpis varchar (1000) not null,
|
---|
91 | izdavacID integer not null references Izdavac(izdavacID)
|
---|
92 |
|
---|
93 |
|
---|
94 | );
|
---|
95 |
|
---|
96 |
|
---|
97 | create table Dodava
|
---|
98 | (
|
---|
99 | bibliotekarID integer not null references Bibliotekar(bibliotekarID),
|
---|
100 | knigaID integer not null references Knigi(knigaID),
|
---|
101 | constraint pk_dodava primary key (bibliotekarID, knigaID)
|
---|
102 | );
|
---|
103 |
|
---|
104 |
|
---|
105 | create table Avtor
|
---|
106 | (
|
---|
107 | avtorID integer primary key not null,
|
---|
108 | aEmail varchar (100) not null,
|
---|
109 | aIme varchar (100) not null
|
---|
110 | );
|
---|
111 |
|
---|
112 |
|
---|
113 | create table Napisal
|
---|
114 | (
|
---|
115 | avtorID integer not null references Avtor(avtorID),
|
---|
116 | knigaID integer not null references Knigi(knigaID),
|
---|
117 | constraint pk_napisal primary key (avtorID, knigaID)
|
---|
118 | );
|
---|
119 |
|
---|
120 | create table Kategorija
|
---|
121 | (
|
---|
122 | kategorijaID integer primary key not null,
|
---|
123 | naslovKategorija varchar (100) not null
|
---|
124 | );
|
---|
125 |
|
---|
126 | create table Klasificira
|
---|
127 | (
|
---|
128 | kategorijaID integer not null references Kategorija(kategorijaID),
|
---|
129 | knigaID integer not null references Knigi(knigaID),
|
---|
130 | constraint pk_ima primary key (kategorijaID, knigaID)
|
---|
131 | );
|
---|
132 |
|
---|
133 | create table Ocena
|
---|
134 | (
|
---|
135 | ocenaID integer primary key not null,
|
---|
136 | ocenka numeric CHECK(ocenka >= 0 AND ocenka <= 10),
|
---|
137 | komentar varchar (1000),
|
---|
138 | avtorID integer not null references Avtor(avtorID),
|
---|
139 | knigaID integer not null references Knigi(knigaID),
|
---|
140 | clenskiBr integer not null references Clen(clenskiBr)
|
---|
141 | );
|
---|
142 |
|
---|
143 | create table InstancaKniga
|
---|
144 | (
|
---|
145 |
|
---|
146 | knigaID integer not null references Knigi(knigaID),
|
---|
147 | seriskiBr integer not null,
|
---|
148 | iStatus varchar(1000) not null,
|
---|
149 | bibliotekaID integer not null references Biblioteka(bibliotekaID),
|
---|
150 | constraint pk_instanca_kniga primary key(knigaID, seriskiBr)
|
---|
151 | );
|
---|
152 |
|
---|
153 |
|
---|
154 | create table Pozajmica
|
---|
155 | (
|
---|
156 | pozajmicaID integer primary key not null,
|
---|
157 | pStatus varchar(1000) not null,
|
---|
158 | pocetokDatum date not null,
|
---|
159 | krajDatum date not null,
|
---|
160 | knigaID integer not null,
|
---|
161 | seriskiBr integer not null,
|
---|
162 | constraint validenIntervalDatumi check (pocetokDatum < krajDatum),
|
---|
163 | foreign key(knigaID, seriskiBr) references InstancaKniga(knigaID, seriskiBr)
|
---|
164 | );
|
---|
165 |
|
---|
166 |
|
---|
167 | create table Rezervacija
|
---|
168 | (
|
---|
169 | rezervacijaID integer primary key not null,
|
---|
170 | rStatus varchar(1000) not null,
|
---|
171 | denNaRezervacija date not null,
|
---|
172 | pozajmicaID integer not null references Pozajmica(pozajmicaID),
|
---|
173 | bibliotekarID integer not null references Bibliotekar(bibliotekarID),
|
---|
174 | knigaID integer not null references Knigi(knigaID),
|
---|
175 | clenskiBr integer not null references Clen(clenskiBr)
|
---|
176 | );
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 |
|
---|
182 |
|
---|
183 |
|
---|
184 |
|
---|
185 |
|
---|
186 |
|
---|
187 |
|
---|