Design And Implementation Of A Hotel Booking System Database

Application Description

The proposed application is a hotel booking system that will be used to manage hotel facilities and services as well as guest and booking records generated on a daily basis by the hotel. To discuss the requirements of the proposed application a hotel named comfy-inn is considered as the case study. Comfy-inn accepts invitations for bookings from its guests via phone call. Once a call is received, if the guest is a new guest, the details of the guest are recorded.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

The receptionist then gives a list of rooms that are available for booking and some of the services that are available at the rooms. The guest gives the booking details and a booking for a room is made for that customer. The customer can also specify other services that he or she would like to be included in the room. On the day of check in the guest checks in and continues with the stay. During checkout, the amount accrued for the guest is calculated and the customer pays using any of the payment methods accepted by the hotel. The customer can also give notes on how the stay was or can review the staff that served them.

Based on the requirements an application can be developed to help manage the hotel. The application should be able to record guest details. It should also keep records of all the rooms and services that are available in those rooms. The application should enable bookings to be made for guests and should record any notes that are made by guests. On the checkout date, the application should be able to record payment details resulting to a payment. It should also keep a record of the staff working in the hotel and their roles within the system.

 Database analysis

Analysis of the database for performance and redundancy involves making sure that all the tables are in 3NF and for those tables that are not in 3NF, providing a justification on why there is no sense in going all the way to 3NF. Based on the ERD shown in step 3 above, all the relations shown in the ERD are in 3NF because they all meet the following conditions;

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
  • No table has repeating groups thus all relations are qualify to be in 1NF.
  • No table has partial dependencies thus they all qualify to be in 2NF. This means that no relation has a non-prime attribute that is functionally dependent on part the candidate key for each table.
  • No table has any transitive dependencies thus all relations qualify to be in 3NF. This means that each entity shown in the entity relationship diagram has only one key attribute which is the primary key of the table. The key attribute functionally determines all the other attributes.

By using this bottom-up approach, the database design can be verified to be in 3NF meaning that the database will perform optimally and no data redundancies will occur in the database.

For a relation to be in BCNF the following conditions must hold for that relation;

  • The relation must be in 3NF.
  • For any dependency XàY, X should be a super key.

Based on the ERD shown in step 2 above, all the relations meet all the conditions for BCNF because all relations are in 3NF and for any dependency XàY, X is the superkey.

Normalization to BCNF is important for a database it helps achieve more prevention of data redundancy in the database. This in turn helps in minimizing the disk space used for the database.

Database implementation

Code

CREATE DATABASE IF NOT EXISTS hotel DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

USE hotel;

CREATE TABLE IF NOT EXISTS booking (

Database Analysis

bookingID int(11) NOT NULL,

  `date` date NOT NULL,

  noOfAdults int(11) NOT NULL,

  noOfChildren int(11) NOT NULL,

  expectedArrivalTime datetime NOT NULL,

  expectedDepartureTime datetime NOT NULL,

  `status` varchar(10) NOT NULL,

  guestID int(11) NOT NULL,

  roomNO int(11) NOT NULL

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS booking_services (

  bokingID int(11) NOT NULL,

  serviceID int(11) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS guest (

guestID int(11) NOT NULL,

  firstName varchar(100) NOT NULL,

  lastName varchar(100) NOT NULL,

  suburb varchar(100) NOT NULL,

  telNo varchar(25) DEFAULT NULL,

  email varchar(250) NOT NULL

) ENGINE=InnoDB AUTO_INCREMENT=160028 DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS guest_notes (

noteID int(11) NOT NULL,

  note text NOT NULL,

  guestID int(11) NOT NULL,

  staffID int(11) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS payment (

  paymentID int(11) NOT NULL,

  bookingID int(11) NOT NULL,

  paymentTypeID int(11) NOT NULL,

  amount double NOT NULL,

  `date` date NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS payment_types (

paymentTypeID int(11) NOT NULL,

  `type` varchar(50) NOT NULL,

  `name` varchar(50) NOT NULL

) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS rooms (

roomNO int(11) NOT NULL,

  `type` varchar(50) NOT NULL,

  rate double NOT NULL,

  noOfBeds int(11) NOT NULL

) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS services (

serviceID int(11) NOT NULL,

  `type` varchar(50) NOT NULL,

  details varchar(50) NOT NULL,

  charges double NOT NULL,

  roomNO int(11) NOT NULL

) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS staff (

stafID int(11) NOT NULL,

  firstName varchar(100) NOT NULL,

  lastName varchar(100) NOT NULL,

  email varchar(250) NOT NULL,

  address varchar(250) NOT NULL

) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS users (

  staffID int(11) NOT NULL,

  `function` varchar(25) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE booking

 ADD PRIMARY KEY (bookingID), ADD KEY roomNO (roomNO), ADD KEY guestID (guestID);

ALTER TABLE booking_services

 ADD KEY bokingID (bokingID,serviceID), ADD KEY serviceID (serviceID);

ALTER TABLE guest

 ADD PRIMARY KEY (guestID);

ALTER TABLE guest_notes

 ADD PRIMARY KEY (noteID), ADD KEY guestID (guestID), ADD KEY guestID_2 (guestID), ADD KEY staffID (staffID), ADD KEY staffID_2 (staffID);

ALTER TABLE payment

 ADD KEY bookingID (bookingID,paymentTypeID), ADD KEY paymentTypeID (paymentTypeID);

ALTER TABLE payment_types

 ADD PRIMARY KEY (paymentTypeID);

ALTER TABLE rooms

 ADD PRIMARY KEY (roomNO);

ALTER TABLE services

 ADD PRIMARY KEY (serviceID), ADD KEY roomNO (roomNO);

ALTER TABLE staff

 ADD PRIMARY KEY (stafID);

ALTER TABLE users

 ADD KEY staffID (staffID);

ALTER TABLE booking

MODIFY bookingID int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;

ALTER TABLE guest

MODIFY guestID int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=160028;

ALTER TABLE guest_notes

MODIFY noteID int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE payment_types

MODIFY paymentTypeID int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;

ALTER TABLE rooms

MODIFY roomNO int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=24;

ALTER TABLE services

MODIFY serviceID int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;

ALTER TABLE staff

MODIFY stafID int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;

ALTER TABLE booking

ADD CONSTRAINT booking_ibfk_3 FOREIGN KEY (guestID) REFERENCES guest (guestID) ON UPDATE CASCADE,

ADD CONSTRAINT booking_ibfk_4 FOREIGN KEY (roomNO) REFERENCES rooms (roomNO) ON UPDATE CASCADE;

ALTER TABLE booking_services

ADD CONSTRAINT booking_services_ibfk_2 FOREIGN KEY (serviceID) REFERENCES services (serviceID) ON DELETE CASCADE ON UPDATE CASCADE,

Database Implementation

ADD CONSTRAINT booking_services_ibfk_3 FOREIGN KEY (bokingID) REFERENCES booking (bookingID) ON UPDATE CASCADE;

ALTER TABLE guest_notes

ADD CONSTRAINT guest_notes_ibfk_1 FOREIGN KEY (guestID) REFERENCES guest (guestID) ON DELETE CASCADE ON UPDATE CASCADE,

ADD CONSTRAINT guest_notes_ibfk_2 FOREIGN KEY (staffID) REFERENCES staff (stafID) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE payment

ADD CONSTRAINT payment_ibfk_1 FOREIGN KEY (paymentTypeID) REFERENCES payment_types (paymentTypeID) ON DELETE CASCADE ON UPDATE CASCADE,

ADD CONSTRAINT payment_ibfk_2 FOREIGN KEY (bookingID) REFERENCES booking (bookingID) ON UPDATE CASCADE;

ALTER TABLE services

ADD CONSTRAINT services_ibfk_1 FOREIGN KEY (roomNO) REFERENCES rooms (roomNO) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE users

ADD CONSTRAINT users_ibfk_1 FOREIGN KEY (staffID) REFERENCES staff (stafID) ON DELETE CASCADE ON UPDATE CASCADE;

/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;

/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;

/*!40101 SET @[email protected]@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

— Database: `hotel`

— Dumping data for table `booking`

INSERT INTO `booking` VALUES(1, ‘2017-09-18’, 1, 0, ‘2017-10-01 14:33:37’, ‘2017-11-02 12:33:37’, ‘Confirmed’, 1, 18);

INSERT INTO `booking` VALUES(2, ‘2018-10-11’, 2, 0, ‘2018-10-16 07:17:17’, ‘2018-11-16 07:17:17’, ‘confirmed’, 2, 19);

INSERT INTO `booking` VALUES(3, ‘2018-10-21’, 1, 0, ‘2018-10-31 07:21:22’, ‘2018-11-02 06:17:16’, ‘pending’, 2, 19);–

— Dumping data for table `booking_services`

INSERT INTO `booking_services` VALUES(1, 1);

INSERT INTO `booking_services` VALUES(2, 2);

— Dumping data for table `guest`

INSERT INTO `guest` VALUES(1, ‘peter’, ‘Griffin’, ‘Rhode island hill’, NULL, ‘[email protected]‘);

INSERT INTO `guest` VALUES(2, ‘cleveland ‘, ‘brown’, ‘cleveland drive’, ‘+567890233’, ‘[email protected]‘);

INSERT INTO `guest` VALUES(5, ‘JOn ‘, ‘snow’, ‘Winterfell avenue’, ‘+456723434’, ‘[email protected]‘);

INSERT INTO `guest` VALUES(6, ‘arya’, ‘stark’, ‘winterfell drive’, ”, ‘[email protected]‘);

INSERT INTO `guest` VALUES(7, ‘Samwell’, ‘Tally’, ‘Nights watch avenue’, ‘+32434234’, ‘[email protected]‘);

INSERT INTO `guest` VALUES(8, ‘cercei’, ‘lannister’, ‘Kings landing hill’, ‘+567823434’, ‘[email protected]‘);

INSERT INTO `guest` VALUES(9, ‘Geoffrey ‘, ‘baratheon’, ‘Kings landing’, ‘+324324534’, ‘[email protected]‘);

— Dumping data for table `payment`

INSERT INTO `payment` VALUES(1, 1, 4, 3422, ‘2014-10-04’);

INSERT INTO `payment` VALUES(2, 2, 4, 2342, ‘2017-10-25’);

INSERT INTO `payment` VALUES(0, 3, 4, 3443, ‘2017-11-07’);

INSERT INTO `payment` VALUES(3, 3, 4, 3443, ‘2017-11-07’);

— Dumping data for table `payment_types`

INSERT INTO `payment_types` VALUES(1, ‘Credit Card’, ‘Visa’);

INSERT INTO `payment_types` VALUES(2, ‘Credit Card’, ‘Mastercard’);

INSERT INTO `payment_types` VALUES(3, ‘Credit Card’, ‘American Express’);

INSERT INTO `payment_types` VALUES(4, ‘Cash’, ‘Cash’);

— Dumping data for table `rooms`

INSERT INTO `rooms` VALUES(18, ‘deluxe’, 200, 2);

INSERT INTO `rooms` VALUES(19, ‘deluxe’, 150, 1);

INSERT INTO `rooms` VALUES(20, ‘Suite’, 2434, 1);

INSERT INTO `rooms` VALUES(21, ‘Suite’, 3242, 1);

INSERT INTO `rooms` VALUES(22, ‘Twinshare’, 2343, 2);

INSERT INTO `rooms` VALUES(23, ‘Twinshare’, 2312, 2);–

— Dumping data for table `services`

INSERT INTO `services` VALUES(1, ‘Jacuzi’, ‘Jacuzi on the balcony’, 50, 18);

INSERT INTO `services` VALUES(2, ‘Wifi’, ‘Wifi in the whole room’, 20, 19);

INSERT INTO `services` VALUES(3, ‘service’, ‘spa’, 21, 20);

INSERT INTO `services` VALUES(4, ‘service’, ‘massage’, 21, 21);

umping data for table `staff`

INSERT INTO `staff` VALUES(1, ‘Jon’, ‘Snow’, ‘[email protected]‘, ‘winterfell’);

INSERT INTO `staff` VALUES(2, ‘Cersei’, ‘Lannister’, ‘[email protected]‘, ‘kings landing’);

INSERT INTO `staff` VALUES(3, ‘khaleesi’, ‘dragon queen’, ‘[email protected]‘, ‘123 the north’);

INSERT INTO `staff` VALUES(4, ‘peter’, ‘griffin’, ‘[email protected]‘, ‘213 AVENUE’);

 Dumping data for table `users`

INSERT INTO `users` VALUES(1, ‘payments’);

INSERT INTO `users` VALUES(2, ‘booking’);

  1. Name of customers who have bookings that are still pending.

SELECT concat(firstname,’ ‘ , lastname), booking.date from guest inner join booking on booking.guestid=guest.guestid where booking.status=’pending’;

  1. A list of rooms and their facilities

SELECT rooms.*,services.* from rooms inner join services on services.roomno=rooms.roomno;

  1. The total amount of money paid used each type of payment method.

SELECT pt.name,pt.type,sum(p.amount) from payment_types pt inner join payment p on p.paymenttypeID=p.paymenttypeID group by pt.paymenttypeID;

 How to make the database more efficient for scale

To make the database more efficient for scale, there are a number of factors that can be considered; these factors include;

  • Identifying any bottlenecks that can affect scalability in the future- Scaling the database can cause degraded performance leading to a slow database. It’s important to identify factors that might cause the database to slow down if it was to be scaled in the future. It’s not right to just increase resources without identifying the bottlenecks that might cause slowing down if the database were to be scaled even further.
  • Ensuring the database has no data redundancy. This should be done at the design stage and testing stage of the development such that when the database is scaled in the future, the database will occupy the right amount of space thus it can be scaled without adding too much memory.
  • Considering new technologies during the design of the database. Database systems are constantly and new types of databases are on the rise every day thus its important to consider how the database can be changed to be used in the new database systems which offer more scalability.Code to export database to csv

This can be done using PHP as shown in this code

Function exportToFile($table,$fileName){

header(‘Content-Type: text/csv; charset=utf-8’);  

      header(‘Content-Disposition: attachment; filename=$filename);  

      $output = fopen(“php://output”, “w”); 

$db= new mysqli(“localhost”,”root”,””,”db_name”) or die(‘could not connect to database’);

      $query = $db->query(“SELECT * from $table”);

      while($row = mysqli_fetch_array($result))  

What Will You Get?

We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.

Premium Quality

Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.

Experienced Writers

Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.

On-Time Delivery

Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.

24/7 Customer Support

Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.

Complete Confidentiality

Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.

Authentic Sources

We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.

Moneyback Guarantee

Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.

Order Tracking

You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.

image

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

image

Trusted Partner of 9650+ Students for Writing

From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.

Preferred Writer

Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.

Grammar Check Report

Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.

One Page Summary

You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.

Plagiarism Report

You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.

Free Features $66FREE

  • Most Qualified Writer $10FREE
  • Plagiarism Scan Report $10FREE
  • Unlimited Revisions $08FREE
  • Paper Formatting $05FREE
  • Cover Page $05FREE
  • Referencing & Bibliography $10FREE
  • Dedicated User Area $08FREE
  • 24/7 Order Tracking $05FREE
  • Periodic Email Alerts $05FREE
image

Services offered

Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.

  • On-time Delivery
  • 24/7 Order Tracking
  • Access to Authentic Sources
Academic Writing

We create perfect papers according to the guidelines.

Professional Editing

We seamlessly edit out errors from your papers.

Thorough Proofreading

We thoroughly read your final draft to identify errors.

image

Delegate Your Challenging Writing Tasks to Experienced Professionals

Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!

Check Out Our Sample Work

Dedication. Quality. Commitment. Punctuality

Categories
All samples
Essay (any type)
Essay (any type)
The Value of a Nursing Degree
Undergrad. (yrs 3-4)
Nursing
2
View this sample

It May Not Be Much, but It’s Honest Work!

Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.

0+

Happy Clients

0+

Words Written This Week

0+

Ongoing Orders

0%

Customer Satisfaction Rate
image

Process as Fine as Brewed Coffee

We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.

See How We Helped 9000+ Students Achieve Success

image

We Analyze Your Problem and Offer Customized Writing

We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.

  • Clear elicitation of your requirements.
  • Customized writing as per your needs.

We Mirror Your Guidelines to Deliver Quality Services

We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.

  • Proactive analysis of your writing.
  • Active communication to understand requirements.
image
image

We Handle Your Writing Tasks to Ensure Excellent Grades

We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.

  • Thorough research and analysis for every order.
  • Deliverance of reliable writing service to improve your grades.
Place an Order Start Chat Now
image

Order your essay today and save 30% with the discount code ESSAYHELP