[1563111] | 1 | -- DROP SCHEMA "Project";
|
---|
| 2 |
|
---|
| 3 | CREATE SCHEMA "Project" AUTHORIZATION db_202122z_va_prj_freeparkingspace_owner;
|
---|
| 4 |
|
---|
| 5 | create table Najava(
|
---|
| 6 | Korisnicko_ime varchar(150) primary key,
|
---|
| 7 | EMBG varchar(13) not null,
|
---|
| 8 | Br_tel varchar(30) not null,
|
---|
| 9 | Email varchar(150) not null,
|
---|
| 10 | password varchar(50) not null,
|
---|
| 11 | Ime varchar(150) not null,
|
---|
| 12 | Prezime varchar(150) not null
|
---|
| 13 | );
|
---|
| 14 |
|
---|
| 15 | create table Vraboten(
|
---|
| 16 | Id_vraboten serial not null,
|
---|
| 17 | Uloga varchar(50) not null,
|
---|
| 18 | Korisnicko_ime varchar(150) primary key,
|
---|
| 19 |
|
---|
| 20 | constraint fk_Korisnicko_ime foreign key (Korisnicko_ime) references Najava (Korisnicko_ime)
|
---|
| 21 | );
|
---|
| 22 |
|
---|
| 23 | create table Administrator (
|
---|
| 24 | Id_administrator serial not null,
|
---|
| 25 | Korisnicko_ime varchar(150) primary key,
|
---|
| 26 |
|
---|
| 27 | constraint fk_Korisnicko_ime foreign key (Korisnicko_ime) references Najava (Korisnicko_ime)
|
---|
| 28 | );
|
---|
| 29 |
|
---|
| 30 | create table Kontroler (
|
---|
| 31 | Id_kontroler serial not null,
|
---|
| 32 | Korisnicko_ime varchar(150) primary key,
|
---|
| 33 |
|
---|
| 34 | constraint fk_Korisnicko_ime foreign key (Korisnicko_ime) references Najava (Korisnicko_ime)
|
---|
| 35 | );
|
---|
| 36 |
|
---|
| 37 | create table Kancelar (
|
---|
| 38 | Id_kancelar serial not null,
|
---|
| 39 | Korisnicko_ime varchar(150) primary key,
|
---|
| 40 |
|
---|
| 41 | constraint fk_Korisnicko_ime foreign key (Korisnicko_ime) references Najava (Korisnicko_ime)
|
---|
| 42 | );
|
---|
| 43 |
|
---|
| 44 | create table Ime_na_parking (
|
---|
| 45 | Id_ime integer primary key,
|
---|
| 46 | Lokacija varchar(150) not null,
|
---|
| 47 | Administrator_Korisnicko_ime varchar(150) not null,
|
---|
| 48 |
|
---|
| 49 | constraint fk_Administrator_Korisnicko_ime foreign key (Administrator_Korisnicko_ime) references Administrator (Korisnicko_ime)
|
---|
| 50 | );
|
---|
| 51 |
|
---|
| 52 | create table Zona (
|
---|
| 53 | Id_zona varchar (20) primary key,
|
---|
| 54 | Ime_na_parking_Id_Ime integer not null,
|
---|
| 55 |
|
---|
| 56 | constraint fk_Ime_na_parking foreign key (Ime_na_parking_Id_Ime) references Ime_na_parking (Id_ime)
|
---|
| 57 | );
|
---|
| 58 |
|
---|
| 59 | create table Parking_mesto (
|
---|
| 60 | Broj_na_pmesta integer primary key,
|
---|
| 61 | IdZona varchar(20) not null,
|
---|
| 62 |
|
---|
| 63 | constraint fk_IdZona foreign key (IdZona) references Zona (Id_zona)
|
---|
| 64 | );
|
---|
| 65 |
|
---|
| 66 | create table Korisnik(
|
---|
| 67 | Id_korisnik serial not null,
|
---|
| 68 | Korisnicko_ime varchar(150) primary key,
|
---|
| 69 |
|
---|
| 70 | constraint fk_Korisnicko_ime foreign key (Korisnicko_ime) references Najava (Korisnicko_ime)
|
---|
| 71 | );
|
---|
| 72 |
|
---|
| 73 | create table Avtomobil(
|
---|
| 74 | Reg_tablica varchar(10) primary key,
|
---|
| 75 | Marka varchar(20) not null,
|
---|
| 76 | Boja varchar (15),
|
---|
| 77 | Korisnickoime varchar(150) not null,
|
---|
| 78 |
|
---|
| 79 | constraint fk_Korisnickoime foreign key (Korisnickoime) references Korisnik (Korisnicko_ime)
|
---|
| 80 | );
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | create table Plakjanje (
|
---|
| 84 | Id_plakanje integer primary key,
|
---|
| 85 | Korisnickoime varchar(150) not null,
|
---|
| 86 | Br_tel varchar(30),
|
---|
| 87 | Br_na_smetka varchar(150),
|
---|
| 88 | Tip_plakjanje varchar(150) not null,
|
---|
| 89 |
|
---|
| 90 | constraint fk_Korisnickoime foreign key (Korisnickoime) references Korisnik (Korisnicko_ime),
|
---|
| 91 | constraint ck_tip_plakjanje check (case when tip_plakjanje='mobilno' then Br_tel!= 'not null' when tip_plakjanje='karticka' then Br_na_smetka!= 'not null' end)
|
---|
| 92 | );
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | create table Kazna (
|
---|
| 96 | Id_kazna integer primary key,
|
---|
| 97 | iznos integer not null,
|
---|
| 98 | broj_kazni integer not null,
|
---|
| 99 | Korisnickoime varchar(150) not null,
|
---|
| 100 |
|
---|
| 101 | constraint fk_Korisnickoime foreign key (Korisnickoime) references Korisnik (Korisnicko_ime)
|
---|
| 102 |
|
---|
| 103 | );
|
---|
| 104 |
|
---|
| 105 | create table Rezervacija (
|
---|
| 106 |
|
---|
| 107 | Id_rezervacija integer primary key,
|
---|
| 108 | pocetno_vreme TIMESTAMP not null,
|
---|
| 109 | krajno_vreme TIMESTAMP not null,
|
---|
| 110 | Reg_tablica varchar(10) not null,
|
---|
| 111 | Broj_na_pmesta integer not null,
|
---|
| 112 | Id_plakanje integer not null ,
|
---|
| 113 |
|
---|
| 114 | constraint fk_Reg_tablica foreign key (Reg_tablica) references Avtomobil (Reg_tablica),
|
---|
| 115 | constraint fk_Broj_na_pmesta foreign key (Broj_na_pmesta) references Parking_mesto (Broj_na_pmesta),
|
---|
| 116 | constraint fk_Id_plakanje foreign key (Id_plakanje) references Plakjanje (Id_plakanje)
|
---|
| 117 | );
|
---|
| 118 |
|
---|
| 119 | create table Kontrola (
|
---|
| 120 | Id_kontrola serial primary key,
|
---|
| 121 | izvrsena_kontrola integer not null,
|
---|
| 122 | vreme_na_kontrola TIMESTAMP not null,
|
---|
| 123 | konstantacija varchar(300) not null,
|
---|
| 124 | Korisnicko_ime varchar(150) not null,
|
---|
| 125 | Broj_na_pmesta integer not null,
|
---|
| 126 | Id_rezervacija integer not null,
|
---|
| 127 | Id_kazna integer not null,
|
---|
| 128 |
|
---|
| 129 | constraint fk_Korisnicko_ime foreign key (Korisnicko_ime) references Kontroler (Korisnicko_ime),
|
---|
| 130 | constraint fk_Broj_na_pmesta foreign key (Broj_na_pmesta) references Parking_mesto (Broj_na_pmesta),
|
---|
| 131 | constraint fk_Id_rezervacija foreign key (Id_rezervacija) references Rezervacija (Id_rezervacija),
|
---|
| 132 | constraint fk_Id_kazna foreign key (Id_kazna) references Kazna (Id_kazna)
|
---|
| 133 | ); |
---|