1 | drop schema if exists project cascade;
|
---|
2 | create schema project;
|
---|
3 |
|
---|
4 | drop table if exists REZERVACIJA_USLUGI;
|
---|
5 | drop table if exists VRABOTENI_USLUGI;
|
---|
6 | drop table if exists TERMIN;
|
---|
7 | drop table if exists REZERVACIJA;
|
---|
8 | drop table if exists BEAUTYCENTER;
|
---|
9 | drop table if exists UPLATA;
|
---|
10 | drop table if exists OCENA;
|
---|
11 | drop table if exists USLUGI;
|
---|
12 | drop table if exists KLIENTI;
|
---|
13 | drop table if exists VRABOTENI;
|
---|
14 | drop table if exists USERS;
|
---|
15 |
|
---|
16 |
|
---|
17 | create table USERS(
|
---|
18 | User_ID serial primary key,
|
---|
19 | Username varchar(100) not null unique,
|
---|
20 | UPassword varchar(100) not null
|
---|
21 | );
|
---|
22 |
|
---|
23 | create table KLIENTI(
|
---|
24 | User_ID integer primary key,
|
---|
25 | Ime varchar(100) not null,
|
---|
26 | Prezime varchar(100),
|
---|
27 | Tel_br varchar(12) not null,
|
---|
28 | E_mail varchar(150),
|
---|
29 |
|
---|
30 | constraint fk_User_ID_klient foreign key (User_ID) references users(User_ID)
|
---|
31 | );
|
---|
32 |
|
---|
33 | create table BEAUTYCENTER(
|
---|
34 | Salon_ID varchar(100) primary key,
|
---|
35 | Adresa varchar(100) not null,
|
---|
36 | Tel_br varchar(12) not null,
|
---|
37 | E_mail varchar(100)
|
---|
38 | );
|
---|
39 |
|
---|
40 | create table VRABOTENI(
|
---|
41 | User_ID integer primary key,
|
---|
42 | First_name varchar(100) not null,
|
---|
43 | Middle_name varchar(100),
|
---|
44 | Prezime varchar(100),
|
---|
45 | E_mail varchar(100) not null,
|
---|
46 | Tel_br varchar(12),
|
---|
47 | Rab_iskustvo integer,
|
---|
48 | Salon_ID varchar(100) not null,
|
---|
49 | raboti_od timestamp not null,
|
---|
50 | raboti_do timestamp,
|
---|
51 |
|
---|
52 | constraint fk_Salon_ID foreign key (Salon_ID) references beautycenter(Salon_ID) ,
|
---|
53 | constraint fk_User_ID_vraboten foreign key (User_ID) references users(User_ID)
|
---|
54 | );
|
---|
55 |
|
---|
56 | create table UPLATA(
|
---|
57 | Uplata_ID serial primary key,
|
---|
58 | Informacii varchar(100)
|
---|
59 | );
|
---|
60 | create table TERMINI(
|
---|
61 | Termin_ID serial primary key,
|
---|
62 | Pocetok timestamp not null,
|
---|
63 | Vremetraenje integer,
|
---|
64 | User_ID_vraboten integer not null,
|
---|
65 |
|
---|
66 | constraint fk_User_ID_vraboten foreign key (User_ID_vraboten) references vraboteni(User_ID)
|
---|
67 | );
|
---|
68 |
|
---|
69 | create table REZERVACIJA(
|
---|
70 | Br_rez serial primary key,
|
---|
71 | User_ID_klient integer not null,
|
---|
72 | Termin_ID integer not null,
|
---|
73 | Uplata_ID integer,
|
---|
74 | User_ID_vraboten integer,
|
---|
75 |
|
---|
76 |
|
---|
77 | constraint fk_User_ID_klient foreign key (User_ID_klient) references klienti(User_ID),
|
---|
78 | constraint fk_Termin_ID foreign key (Termin_ID) references termini(Termin_ID),
|
---|
79 | constraint fk_Uplata_ID foreign key (Uplata_ID) references uplata(Uplata_ID),
|
---|
80 | constraint fk_User_ID_vraboten foreign key (User_ID_vraboten) references vraboteni(User_ID)
|
---|
81 |
|
---|
82 | );
|
---|
83 |
|
---|
84 | create table USLUGI(
|
---|
85 | Usluga_ID varchar(100) primary key,
|
---|
86 | Dejnost varchar(100),
|
---|
87 | Cena varchar(100) not null
|
---|
88 | );
|
---|
89 |
|
---|
90 | create table OCENA(
|
---|
91 | Ocena_ID serial primary key,
|
---|
92 | Vrednost integer not null,
|
---|
93 | Komentar varchar(200),
|
---|
94 | User_ID_klient integer not null,
|
---|
95 | Usluga_ID varchar(100) not null,
|
---|
96 | br_rez integer,
|
---|
97 |
|
---|
98 |
|
---|
99 | constraint fk_User_ID_klient foreign key (User_ID_klient) references klienti(User_ID),
|
---|
100 | constraint fk_Usluga_ID foreign key (Usluga_ID) references uslugi(Usluga_ID),
|
---|
101 | constraint fk_Br_rez foreign key (br_rez) references rezervacija(br_rez)
|
---|
102 | );
|
---|
103 |
|
---|
104 | create table REZERVACIJA_USLUGI(
|
---|
105 | Br_rez integer not null,
|
---|
106 | Usluga_ID varchar(100) not null,
|
---|
107 |
|
---|
108 | constraint pk_rezervacija_uslugi primary key (Br_rez, Usluga_ID),
|
---|
109 | constraint fk_Br_rez foreign key (br_rez) references rezervacija(br_rez),
|
---|
110 | constraint fk_Usluga_ID foreign key (Usluga_ID) references uslugi(Usluga_ID)
|
---|
111 | );
|
---|
112 |
|
---|
113 | create table VRABOTENI_USLUGI(
|
---|
114 | User_ID_vraboten integer not null,
|
---|
115 | Usluga_ID varchar(100) not null,
|
---|
116 |
|
---|
117 | constraint pk_vraboteni_uslugi primary key (User_ID_vraboten, Usluga_ID),
|
---|
118 | constraint fk_User_ID_vraboten foreign key (User_ID_vraboten) references vraboteni(User_ID),
|
---|
119 | constraint fk_Usluga_ID foreign key (Usluga_ID) references uslugi(Usluga_ID)
|
---|
120 | );
|
---|
121 |
|
---|
122 |
|
---|
123 |
|
---|