Professional Documents
Culture Documents
DBMS Project Report (21204012) PDF
DBMS Project Report (21204012) PDF
Project Report
JANUARY 2023
Canadian University of Bangladesh
Department of Computer Science and Engineering
Member list
No. Full name ID
1 Minhazul Islam 21204012
Contents
1 Overview 4
3 Schema Diagram 6
6 Frontend Tools 35
7 Conclusions 36
1 Overview
The main objective of this project is to create a database management system for a hotel.The hotel can have
multiple chains, which can further have multiple hotels. Therefore, we need an organised management system,
which can easily manage all the operations and data of the hotel chains and hotels respectively. We will be
managing the below areas of the hotel database management system.
– The hotel chains, their details.
– The hotels in each chain and their details and other information like the rooms and their description and
discounts, etc.
– Information about employees and departments they work in.
– Information about guests.
– Managing bookings and other services used by the guests.
3 Schema Diagram
The schema of the database is given below:
listings color
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT "fk_bookings_employees1"
FOREIGN KEY ("employees_emp_id" )
REFERENCES "hotel_database"."employees" ("emp_id" )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
addresses.state,
addresses.zipcode
FROM hotel_database.guests
JOIN hotel_database.addresses ON addresses.address_id = guests.addresses_address_id
WHERE (guests.guest_id IN ( SELECT DISTINCT bookings.guests_guest_id
FROM hotel_database.bookings
WHERE bookings.hotel_hotel_id = 1));
4.3 Queries :
How many distinct guest have made bookings for a particular month?
RA Expression :
Πguest_f irst_name,guest_last_name,guest_contact_number (σguest_id IN(Πguests_guest_id (bookings))(guests))
How many distinct guest have made bookings for a particular month?
SELECT guest_first_name, guest_last_name,guest_contact_number
FROM hotel_database.guests
WHERE guest_id IN
( SELECT distinct guests_guest_id
FROM hotel_database.bookings
WHERE EXTRACT(MONTH FROM booking_date) = 8);
RA Expression :
Πguest_f irst_name,guest_last_name,guest_contact_number (σguest_id IN (Πguests_guest_id
RA Expression :
ΠT otalHotels (hotel_chain_has_hotel)
RA Expression :
Πhotel_name (hotel ▷◁ σcity=′ M umbai′ (addresses))
Find the names and email addresses of all guests who have booked a room for more than 7 days
SELECT guest_first_name, guest_last_name, guest_email_address
FROM hotel_database.guests
JOIN hotel_database.bookings ON guests.guest_id = bookings.guests_guest_id
WHERE CAST(duration_of_stay AS INTEGER) > 7;
RA Expression :
Πguest_f irst_name,guest_last_name,guest_email_address (guests ▷◁ σCAST (duration_of _stay AS IN T EGER) > 7(bookings)
Find the names of all guests who have used the ’Laundry’ service
SELECT guest_first_name, guest_last_name
FROM hotel_database.guests
JOIN hotel_database.bookings ON guests.guest_id = bookings.guests_guest_id
JOIN hotel_database.hotel_services_used_by_guests ON bookings.booking_id =
hotel_services_used_by_guests.bookings_booking_id
JOIN hotel_database.hotel_services ON hotel_services_used_by_guests.hotel_services_service_id =
hotel_services.service_id
WHERE service_name = 'Laundry';
RA Expression :
Πguest_f irst_name,guest_last_name (guests ▷◁ bookings ▷◁ hotel_services_used_by_guests ▷◁
σservice_name=′ Laundry′ (hotel_services))
Find the names and contact numbers of all employees who work at the hotel with ID ’1’
SELECT emp_first_name, emp_last_name, emp_contact_number
FROM hotel_database.employees
WHERE hotel_hotel_id = '1';
RA Expression :
Πemp_f irst_name,emp_last_name,emp_contact_number (σhotel_hoteli d=′ 1′ (employees))
Find the total number of rooms booked for each month in 2018
SELECT EXTRACT(MONTH FROM booking_date) as month, SUM(total_rooms_booked) as total_rooms_booked
FROM hotel_database.bookings
WHERE EXTRACT(YEAR FROM booking_date) = 2018
GROUP BY month;
RA Expression :
month GSU M (total_rooms_booked) (Πmonth,total_rooms_booked (σEXT RACT (Y EAR F ROM booking_date)=2018 (bookings)))
Find the names of all hotels that are part of the ’China Town Hotels’ chain
SELECT hotel_name
FROM hotel_database.hotel
JOIN hotel_database.hotel_chain_has_hotel ON hotel.hotel_id = hotel_chain_has_hotel.hotels_hotel_id
JOIN hotel_database.hotel_chain ON hotel_chain_has_hotel.hotel_chains_hotel_chain_id =
hotel_chain.hotel_chain_id
WHERE hotel_chain_name = 'China Town Hotels';
RA Expression :
Πhotel_name (hotel ▷◁ hotel_chain_has_hotel ▷◁ σhotel_chain_name=′ China T own Hotels′ (hotel_chain))
Listing:
RA Expression :
Find the names of all guests who booked a room in a hotel located in a specific city
SELECT g.guest_first_name, g.guest_last_name
FROM hotel_database.guests AS g
CROSS JOIN hotel_database.bookings AS b
CROSS JOIN hotel_database.hotel AS h
CROSS JOIN hotel_database.addresses AS a
WHERE h.hotel_id = b.hotel_hotel_id AND b.guests_guest_id = g.guest_id AND h.addresses_address_id =
a.address_id AND a.city = 'Surrey';
RA Expression :
Πguests.guest_f irst_name,guests.guest_last_name (guests × bookings × hotel × σaddresses.city=′ Surrey′ (addresses))
Find all hotel chains and the hotels they are associated with, along with the address of the head office for each
chain
RA Expression :
Find all bookings and the payment type, along with the name and contact information of the employee who
made the booking, even if the booking was not made by an employee, and the guest’s contact information and
the address of their permanent residence
RA Expression :
Πbookings.∗,employees.∗,guests.∗,addresses.∗ (bookings ▷◁bookings.employees_emp_id = employees.emp_id (employees ▷◁
guests.addresses_address_id = addresses.address_id(guests ▷◁bookings.guests_guest_id = guests.guest_id(addresses)
Find the names and contact numbers of guests who have booked rooms in a hotel located in a city whose name
starts with ’S’ and have used the hotel’s ’Laundry’ service
RA Expression :
Πguest_f irst_name,guest_last_name,guest_contact_number (guests ▷◁ σguest_id IN (Πguests_guest_id (bookings ▷◁
hotel ▷◁ addresses ▷◁ σservice_name=′ Laundry′ (hotel_services))))
Find the names and contact numbers of guests who have booked rooms in a hotel located in a city whose name
starts with ’S’ or ’C’
RA Expression :
Πguest_f irst_name,guest_last_name,guest_contact_number (guests ▷◁ σguest_id IN (Πguests_guest_id (bookings ▷◁
hotel ▷◁ addresses ▷◁ σcity LIKE ′ S%′ ORcity LIKE ′ C%′ (addresses))))
Find all the guests who have used the service "Laundry" during their stay at the hotel
SELECT g.*
FROM hotel_database.guests g
WHERE EXISTS (
SELECT 1
FROM hotel_database.hotel_services_used_by_guests hsug
JOIN hotel_database.hotel_services hs ON hsug.hotel_services_service_id = hs.service_id
WHERE hs.service_name = 'Laundry'
AND hsug.bookings_booking_id IN (
SELECT b.booking_id
FROM hotel_database.bookings b
WHERE b.guests_guest_id = g.guest_id
)
);
RA Expression :
Πg.∗ (guests ▷◁ σEXIST S (hotel_services_used_by_guests▷◁σservice_name=′ Laundry′ (hotel_services))▷◁bookings▷◁σguests_guest_id=g.guest_id (g
Find all the guests who have used a unique service at least once during their stay at the hotel
SELECT DISTINCT g.*
FROM hotel_database.guests g
WHERE EXISTS (
SELECT 1
FROM hotel_database.hotel_services_used_by_guests hsug
WHERE hsug.bookings_booking_id IN (
SELECT b.booking_id
FROM hotel_database.bookings b
WHERE b.guests_guest_id = g.guest_id
)
GROUP BY hsug.bookings_booking_id
HAVING COUNT(DISTINCT hsug.hotel_services_service_id) = 1
);
RA Expression :
Πguests.∗ (guests ▷◁ σEXIST S (Π1 (hotel_services_used_by_guests▷◁bookings▷◁guests▷◁COU N T (DIST IN CT hotel_services_service_id)=1)) (h
Delete all hotel chains that don’t have any hotels associated with them
DELETE
FROM hotel_database.hotel_chain
WHERE hotel_chain_id NOT IN (
SELECT hotel_chains_hotel_chain_id
FROM hotel_database.hotel_chain_has_hotel);
6 Frontend Tools
For the frontend we have decided to use Budibase, as it allows for the deployment of quick and easy CRUD
applications. It meets our needs well and has helped us visualize all the data that we have easier into different
sections we have. In the frontend it is possible for there to be normal "Basic" Users and "Admin" Users. Each
different type of user will see different pages as per their ability to change data/only view data. As an example
and admin would be able to see the data and change/add new data whereas someone with basic access would
only be able to see the data.
7 Conclusions
This was an attempt to create a database management system for hotel where a DBA can easily manage
the hotels, rooms, bookings, guests, employees, departments, services, etc. and other things as well, easily and
quickly. Overall, it is huge area and we tried to cover few of the parts of it.