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.
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;
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;
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 (
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,
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’);
SELECT concat(firstname,’ ‘ , lastname), booking.date from guest inner join booking on booking.guestid=guest.guestid where booking.status=’pending’;
SELECT rooms.*,services.* from rooms inner join services on services.roomno=rooms.roomno;
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;
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))
We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.
Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
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.
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.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
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.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
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.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
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.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
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!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
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.
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.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.