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