Dbms Project ..
Dbms Project ..
normalization
Title of the project :-Travelling website database
BY
Dasari suma – 197124
Bekkam sreyas-197119
Nallapu Rahul- 197154
Under the guidance of
Prof. R. B. V. SUBRAMAANYAM
Dr. T RAMAKRISHNUDU
Problem statement :In this project we have designed data base
management system to design travelling website database.This
website makes our travelling very simple and easy.Every customer
logins through his/her mobile number and website provides booking
id for a particular trip.The customer just have to login to the website
and enter trip details like trip like mode of transportation,trip
ends,no.of people. It provides many online travel services including
flight tickets,hotel reservations etc. The website consults to
travel_agency ,hotel booking site and the booking website gives
every information to user like room number,vechile number,seat
number through mail.And the end the website provides cost of trip
which customer pays with the linked card.The database also gives
data of tourist places,hotels available at particular location.
Contents:
• ER Model Assumptions
• ER Diagram
• Relational Schema before normalisation
• Functional Dependencies and Primary Keys before normalisation
• Normalization
• Functional Dependencies and Primary Keys after normalisation
• SQL Code
• Tables after normalisation
ER Model Assumptions-
•A customer can login into website to plan many trips.But in this
database we are just updating the details when old user logins into
site
•We are just assuming that the no.of rooms travellers want is half of
the total travellers.
•Every customer can hire many cabs but in this database we are just
assuming each customer takes only one cab in entire trip.
•We are assuming that with a specified name and address there is
only one hotel
•We are assuming that at a specified address there is only one
resturant
•Different types of rooms are possible in a particular hotel like
ac/non-ac.Excluding all we are assuming there are only one type of
rooms in a hotel.
•As we are designing travel website database and we can only know
the customers who approached our database so we are treating
travel website as unique
ER DIAGRAM
Relational Schema before normalization
Functional Dependencies and Primary Key
BEFORE NORMALIZATION
1.Customer
Phone_no -> c_name,start_date,return_date,travellers,card_no,trip_expenses
Card_no -> c_name,start_date,return_date,travellers,phone_no,trip_expenses
Primary key – phone_no
2.Cab_services
Phone_no -> capacity
Phone_no -> cab_no
Primary_key – phone_no,cab_no
3.Hotel_site
Booking_id -> stay_place,no_of_travellers,accommodation_charges
Primary key – (booking_id,stay_place)
4.Travel_agency
Booking_id -> start_no,return_no,start_sno,return_sno,travelling_charges
Primary key – booking_id
5.Tourist_places
Spot_name,spot_address ->specality
Spot_name,spot_address -> restaurant_name
Spot_name,spot_address -> rating
restaurant_name -> rating
Spot_address->rating
Primary key – (spot_name,spot_address,destination)
6.Travel_website
Booking_id -> cost,source,destination,start_mode,return_mode,phone_no
Phone_no -> booking_id,cost,source,destination,start_mode,return_mode
Primary key – booking_id
7.Hotel
Booking_id -> name,address,rating,room_rent,no_of_rooms
name,address ->room_rent
name,address ->rating
address -> stay_place
Primary key –(booking_id,stay_place)
NORMALIZATION
1)CUSTOMER1
Primary Key: phone_no
Candidate Key: card_no
All attributes depend on the phone_no,hence the table is 2NF.
All attributes depend directly on the phone_no,hence the table is 2NF.
All determinants(phone_no) are candidate key,hence the table is BCNF.
2) CAB_SERVIES
Primary Key: phone_no
All attributes depend on the phone_no,hence the table is 2NF.
All attributes depend directly on the phone_no,hence the table is 2NF.
All determinants(phone_no) are candidate key,hence the table is BCNF.
3) TRAVEL_WEBSITE
Primary Key :booking_id
Candidate Key: phone_no
All attributes depend on the booking_id,hence the table is 2NF.
All attributes depend directly on the booking_id,hence the table is 2NF.
All determinants(booking_id) are candidate key,hence the table is BCNF.
4) HOTEL_SITE
Primary Key :booking_id
All attributes depend on the booking_id,hence the table is 2NF.
All attributes depend directly on the booking_id,hence the table is 2NF.
All determinants(booking_id) are candidate key,hence the table is BCNF.
5) HOTEL
It was divided into 2 entities because the former one’s highest normal form
was 1NF.
->Hotel1(namee, address, rating, roomrent, booking_id)
Primary Key : booking_id
All attributes depend on the (namee, address),hence the table is 2NF.
All attributes depend directly on the (namee, address),hence the table is 2NF.
All determinants(namee, address) are candidate key,hence the table is BCNF.
2.Cab_services
Phone_no -> capacity
Phone_no -> cab_no
Primary_key – phone_no,cab_no
3.Hotel_site
Booking_id -> stay_place,no_of_travellers,accommodation_charges
Primary key – (booking_id,stay_place)
4.Travel_agency
Booking_id -> start_no,return_no,start_sno,return_sno,travelling_charges
Primary key – booking_id
5.Tourist_places
Spot_name,spot_address ->specality
Spot_name,spot_address -> restaurant_name
Spot_name,spot_address -> rating
restaurant_name -> rating
Spot_address->rating
Primary key – (spot_name,spot_address,destination)
6.Travel_website
Booking_id -> cost,source,destination,start_mode,return_mode,phone_no
Phone_no -> booking_id,cost,source,destination,start_mode,return_mode
Primary key – booking_id
7.Hotel1
Booking_id -> no_of_rooms,stay_place
Primary key – booking_id
8.Hotel2
Booking_id -> name,address,rating,room_rent
name,address -> rating
name,address ->room_rent
Primary key – booking_id
SQL CODE
Creation
CREATE TABLE customer
(
c_name VARCHAR(20),
start_date DATE,
return_date DATE,
travellers INT,
sourcee varchar(20),
destination varchar(20),
phone_no DECIMAL(10),
card_no DECIMAL(20) ,
trip_expenses INT DEFAULT 0,
PRIMARY KEY(phone_no)
);
Insertion
update
UPDATE cab_services
SET capacityy=(SELECT travellers FROM customer WHERE
customer.phone_no=cab_services.phone_no);
UPDATE hotel_site
SET stay_place=(SELECT destination FROM customer NATURAL JOIN
travel_website WHERE travel_website.booking_id=hotel_site.booking_id);
UPDATE hotel_site
SET hotel_site.no_of_travellers=(SELECT travellers FROM customer NATURAL
JOIN travel_website
where hotel_site.booking_id=travel_website.booking_id);
UPDATE hotel1
SET no_of_rooms=(SELECT CEIL(no_of_travellers/2) FROM hotel_site where
hotel_site.booking_id=hotel1.booking_id),
stay_place=(SELECT stay_place FROM hotel_site WHERE
hotel_site.booking_id=hotel1.booking_id);
UPDATE travel_website
SET costt=(SELECT hotel_site.accomodation_charges FROM hotel_site WHERE
hotel_site.booking_id=travel_website.booking_id)+
(SELECT travel_agency.travelling_charges FROM travel_agency WHERE
travel_agency.booking_id=travel_website.booking_id);
UPDATE customer
SET trip_expenses=(SELECT costt FROM travel_website WHERE
travel_website.phone_no=customer.phone_no);
1.customer
2.Travel_website
3.Cab_services
4.Tourist_places
5.Travel_agency
6.Hotel_site
7.Hotel1
8.Hotel2