source: src/main/resources/sqlscripts/DDL2.sql@ f7c05a1

Last change on this file since f7c05a1 was f7c05a1, checked in by Elena Shulevska <elena.shulevska@…>, 15 months ago

initial commit of the source code on origin

  • Property mode set to 100644
File size: 8.1 KB
Line 
1--Villa(villa_id, villa_location, name, villa_view_type)
2create table villa(
3 villa_id integer primary key,
4 villa_location varchar(255) not null,
5 name varchar(255) not null,
6 villa_view_type varchar(255)
7);
8
9
10
11--Events(event_id, event_type, price, number_of_interested_guests)
12create table events(
13 event_id serial primary key,
14 event_type varchar(255) not null,
15 price float not null,
16 number_of_interested_guests integer not null
17);
18
19
20--Activities(activity_id, activity_type, price, number_of_interested_guests, location)
21create table activities(
22 activity_id serial primary key,
23 activity_type varchar(255) not null,
24 price float not null,
25 number_of_interested_guests integer not null,
26 activity_location varchar(255) not null
27);
28
29
30
31--Rooms(room_id, room_type, price,availability, villa_id*)
32create table rooms(
33 room_id integer primary key,
34 room_type varchar(255) not null,
35 price integer not null,
36 availability boolean not null,
37 villa_id integer not null,
38 constraint fk_rooms_villa foreign key(villa_id)
39 references villa(villa_id)
40);
41
42
43--Beverage(beverage_id, beverage_type, price)
44create table beverage(
45 beverage_id integer primary key,
46 beverage_type varchar(255) not null,
47 price float not null
48);
49
50--Product(product_id, number_of_products, product_type)
51create table product(
52 product_id integer primary key,
53 number_of_products integer not null,
54 product_type varchar(255) not null
55);
56
57
58
59
60--Meal(meal_id, price, meal_type)
61create table meal(
62 meal_id serial primary key,
63 price float not null,
64 meal_type varchar(255) not null
65);
66
67
68
69--User_table(user_id, EMBG, address, email, username, password, full_name, phone_number)
70create table user_table(
71 user_id serial primary key,
72 embg char(20) unique not null,
73 address varchar(255) not null,
74 email varchar(255) not null,
75 password varchar(255) not null,
76 username varchar(255) not null,
77 full_name varchar(255) not null,
78 phone_number varchar(255) not null
79);
80
81
82--Payment(payment_id, total_payment, pay_date, rec_id, customer_id, user_id*)
83create table payment(
84 payment_id serial primary key,
85 total_payment float not null,
86 pay_date date not null,
87 rec_id varchar(255) not null,
88 customer_id varchar(255) not null,
89 user_id integer not null,
90 constraint fk_payment_user foreign key (user_id)
91 references user_table(user_id)
92);
93
94
95--Reservation(reservation_id, start_date, end_date, number_guests, adults, children, villa_id*, payment_id*, room_id*)
96create table reservation(
97 reservation_id serial primary key,
98 start_date date not null,
99 end_date date not null,
100 number_guests integer not null,
101 adults integer not null,
102 children integer,
103 villa_id integer not null,
104 payment_id integer not null,
105 room_id integer not null,
106 constraint fk_reservation_villa foreign key (villa_id)
107 references villa(villa_id),
108 constraint fk_reservation_payment foreign key (payment_id)
109 references payment(payment_id),
110 constraint fk_resrvation_room foreign key (room_id)
111 references rooms(room_id)
112);
113
114
115--Log in(login_id, vreme_na_najava, user_id*)
116create table log_in(
117 login_id serial primary key,
118 vreme_na_najava varchar(255) not null,
119 user_id integer not null,
120 constraint fk_login_user foreign key(user_id)
121 references user_table(user_id)
122);
123
124
125
126--Service(service_id, service_type, price, user_id*, room_id*)
127create table service(
128 service_id serial primary key,
129 service_type varchar(255) not null,
130 price float not null,
131 user_id integer not null,
132 room_id integer not null,
133 constraint fk_service_user foreign key(user_id)
134 references user_table(user_id),
135 constraint fk_service_rooms foreign key(room_id)
136 references rooms(room_id)
137);
138
139
140
141--Waiter(user_id*, shift, salary)
142create table waiter(
143 user_id integer primary key,
144 constraint fk_waiter_user foreign key(user_id)
145 references user_table(user_id),
146 shift integer not null,
147 salary float not null
148);
149
150
151--Receptionist(user_id*, shift, salary)
152create table receptionist(
153 user_id integer primary key,
154 constraint fk_receptionist_user foreign key(user_id)
155 references user_table(user_id),
156 shift integer not null,
157 salary float not null
158);
159
160
161--Chef(user_id*, shift, salary)
162create table chef(
163 user_id integer primary key,
164 constraint fk_chef_user foreign key(user_id)
165 references user_table(user_id),
166 shift integer not null,
167 salary float not null
168);
169
170
171--Guests(user_id*, passport_number)
172create table guests(
173 user_id integer primary key,
174 constraint fk_guests_user foreign key(user_id)
175 references user_table(user_id),
176 passport_number varchar(225) not null
177);
178
179
180--Prepared_Meal(prepared_meal_id, meal_id*, user_id*)
181create table prepared_meal(
182 prepared_meal_id serial,
183 meal_id integer not null,
184 user_id integer not null,
185 constraint fk_prepared_meal_meal foreign key(meal_id)
186 references meal(meal_id),
187 constraint fk_prepared_meal_user foreign key(user_id)
188 references user_table(user_id),
189 constraint pk_prepared_meal primary key(meal_id, prepared_meal_id)
190);
191
192
193
194--On_Site(payment_id*, currency, payment_type, user_id* )
195create table on_site(
196 payment_id integer primary key,
197 constraint fk_onsite_payment foreign key(payment_id)
198 references payment(payment_id),
199 currency varchar(255) not null,
200 payment_type varchar(255) not null,
201 user_id integer not null,
202 constraint fk_onsite_user foreign key(user_id)
203 references user_table(user_id)
204);
205
206--Online(payment_id*, card_number)
207create table online(
208 payment_id integer primary key,
209 constraint fk_online_payment foreign key(payment_id)
210 references payment(payment_id),
211 card_number varchar(255) unique not null
212);
213
214
215--reservation_for_events (reservation_id*, event_id*)
216create table reservation_for_events(
217 reservation_id integer,
218 event_id integer,
219 constraint pk_reservation_for_events primary key(reservation_id, event_id),
220 constraint fk_reservation_for_events_r foreign key(reservation_id)
221 references reservation(reservation_id),
222 constraint fk_reservation_for_events_e foreign key(event_id)
223 references events(event_id)
224);
225
226--reservation_for_activity(reservation_id*, activity_id*)
227create table reservation_for_activity(
228 reservation_id integer,
229 activity_id integer,
230 constraint pk_reservation_for_activity primary key(reservation_id, activity_id),
231 constraint fk_reservation_for_activity_r foreign key(reservation_id)
232 references reservation(reservation_id),
233 constraint fk_reservation_for_activity_a foreign key(activity_id)
234 references activities(activity_id)
235);
236
237
238
239--reservation_for_prepared_meal(reservation_id*, (prepared_meal_id*, meal_id*), quantity)
240create table reservation_for_prepared_meal(
241 reservation_id integer,
242 prepared_meal_id integer,
243 meal_id integer,
244 quantity integer not null
245 constraint ck_quantity_gt_0 check (quantity >= 0),
246 constraint pk_reservation_for_prepared_meal primary key(reservation_id, prepared_meal_id, meal_id),
247 constraint fk_reservation_for_prepared_meal_r foreign key(reservation_id)
248 references reservation(reservation_id),
249 constraint fk_reservation_for_prepared_meal_pm foreign key(prepared_meal_id, meal_id)
250 references prepared_meal(prepared_meal_id, meal_id)
251);
252
253--service_for_beverages(service_id*, beverage_id*, quantity)
254create table service_for_beverages(
255 service_id integer,
256 beverage_id integer,
257 quantity integer not null
258 constraint ck_quantity_gt_0 check (quantity >= 0),
259 constraint pk_service_for_beverages primary key(service_id, beverage_id),
260 constraint fk_service_for_beverages_s foreign key(service_id)
261 references service(service_id),
262 constraint fk_service_for_beverages_b foreign key(beverage_id)
263 references beverage(beverage_id)
264);
265
266--meal_madeof_product(meal_id*,product_id* )
267create table meal_made_of_product(
268 meal_id integer,
269 product_id integer,
270 constraint pk_meal_madeof_product primary key(meal_id, product_id),
271 constraint fk_meal_madeof_product_m foreign key(meal_id)
272 references meal(meal_id),
273 constraint fk_meal_madeof_product_p foreign key(product_id)
274 references product(product_id)
275);
276
277-- guests_make_reservation(user_id*,reservation_id* )
278create table guests_make_reservation(
279 user_id integer,
280 reservation_id integer,
281 constraint pk_guests_make_reservation primary key(user_id,reservation_id),
282 constraint fk_guests_make_reservation_u foreign key(user_id)
283 references user_table(user_id),
284 constraint fk_guests_make_reservation_r foreign key(reservation_id)
285 references reservation(reservation_id)
286);
287
Note: See TracBrowser for help on using the repository browser.