Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE TABLE Hotels ( HotelID INT PRIMARY KEY, Name VARCHAR ( 2 5 5 ) , Address VARCHAR ( 2 5 5 ) , City

CREATE TABLE Hotels (
HotelID INT PRIMARY KEY,
Name VARCHAR(255),
Address VARCHAR(255),
City VARCHAR(255),
State VARCHAR(255),
Phone VARCHAR(20)
);
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
Name VARCHAR(255),
Address VARCHAR(255),
Phone VARCHAR(20),
CreditCardInfo VARCHAR(255)
);
CREATE TABLE Reservations (
ReservationID INT PRIMARY KEY,
CustomerID INT,
HotelID INT,
RoomType INT,
StartDate DATE,
EndDate DATE,
Rate DECIMAL(10,2),
DateOfReservation DATE,
TotalAmount DECIMAL(10,2),
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID),
FOREIGN KEY (HotelID) REFERENCES Hotels(HotelID)
);
CREATE TABLE RoomTypes (
RoomTypeID INT PRIMARY KEY,
HotelID INT,
RoomType VARCHAR(255),
PricePerNight DECIMAL(10,2),
Availability INT,
FOREIGN KEY (HotelID) REFERENCES Hotels(HotelID)
);
CREATE TABLE Services (
ServiceID INT PRIMARY KEY,
ServiceType VARCHAR(255),
Price DECIMAL(10,2)
);
CREATE TABLE ReservationServices (
ReservationServiceID INT PRIMARY KEY,
ReservationID INT,
ServiceID INT,
Dt DATE,
Quantity INT,
TotalAmount DECIMAL(10,2),
FOREIGN KEY (ReservationID) REFERENCES Reservations(ReservationID),
FOREIGN KEY (ServiceID) REFERENCES Services(ServiceID)
);
-- Creating the relationship: Reservations to RoomTypes (Many-to-One)
ALTER TABLE Reservations
ADD FOREIGN KEY (RoomType) REFERENCES RoomTypes(RoomTypeID);
-- Insert records into Hotels table
INSERT INTO Hotels (HotelID, Name, Address, City, State, Phone) VALUES
(1, 'Grand Hotel', '123 Main St', 'Springfield', 'IL','217-555-1234');
INSERT INTO Hotels (HotelID, Name, Address, City, State, Phone) VALUES
(2, 'Ocean View', '456 Beach Rd', 'Miami', 'FL','305-555-5678');
INSERT INTO Hotels (HotelID, Name, Address, City, State, Phone) VALUES
(3, 'Mountain Inn', '789 Hill St', 'Denver', 'CO','303-555-9012');
INSERT INTO Hotels (HotelID, Name, Address, City, State, Phone) VALUES
(4, 'City Center Hotel', '1010 City Ave', 'New York', 'NY','212-555-3456');
INSERT INTO Hotels (HotelID, Name, Address, City, State, Phone) VALUES
(5, 'Desert Retreat', '2020 Desert Rd', 'Phoenix', 'AZ','602-555-7890');
-- Insert records into Customers table
INSERT INTO Customers (CustomerID, Name, Address, Phone, CreditCardInfo) VALUES
(1, 'John Doe', '321 Oak St','217-555-4321','4111-1111-1111-1111');
INSERT INTO Customers (CustomerID, Name, Address, Phone, CreditCardInfo) VALUES
(2, 'Jane Smith', '654 Pine St','305-555-8765','4222-2222-2222-2222');
INSERT INTO Customers (CustomerID, Name, Address, Phone, CreditCardInfo) VALUES
(3, 'Robert Brown', '987 Maple St','303-555-2109','4333-3333-3333-3333');
INSERT INTO Customers (CustomerID, Name, Address, Phone, CreditCardInfo) VALUES
(4, 'Emily Davis', '1212 Elm St','212-555-6543','4444-4444-4444-4444');
INSERT INTO Customers (CustomerID, Name, Address, Phone, CreditCardInfo) VALUES
(5, 'Michael Johnson', '3434 Cedar St','602-555-9876','4555-5555-5555-5555');
-- Insert records into RoomTypes table
INSERT INTO RoomTypes (RoomTypeID, HotelID, RoomType, PricePerNight, Availability) VALUES
(1,1, 'Single', 100.00,10);
INSERT INTO RoomTypes (RoomTypeID, HotelID, RoomType, PricePerNight, Availability) VALUES
(2,1, 'Double', 150.00,5);
INSERT INTO RoomTypes (RoomTypeID, HotelID, RoomType, PricePerNight, Availability) VALUES
(3,2, 'Suite', 200.00,2);
INSERT INTO RoomTypes (RoomTypeID, HotelID, RoomType, PricePerNight, Availability) VALUES
(4,3, 'Single', 120.00,8);
INSERT INTO RoomTypes (RoomTypeID, HotelID, RoomType, PricePerNight, Availability) VALUES
(5,4, 'Double', 180.00,6);
-- Insert records into Services table
INSERT INTO Services (ServiceID, ServiceType, Price) VALUES
(1, 'Room Service', 25.00);
INSERT INTO Services (ServiceID, ServiceType, Price) VALUES
(2, 'Spa', 100.00);
INSERT INTO Services (ServiceID, ServiceType, Price) VALUES
(3, 'Gym Access', 15.00);
INSERT INTO Services (ServiceID, ServiceType, Price) VALUES
(4, 'Laundry', 20.00);
INSERT INTO Services (ServiceID, ServiceType, Price) VALUES
(5, 'Parking', 10.00);
-- Insert records into Reservations table
INSERT INTO Reservations (ReservationID, CustomerID, HotelID, RoomType, StartDate, EndDate, Rate, DateOfReservation, TotalAmount) VALUES
(1,1,1,1,'07/01/2024','07/05/2024',100.00,'06/20/2024',500.00);
INSERT INTO Reservations (ReservationID, CustomerID, HotelID, RoomType, StartDate, EndDate, Rate, DateOfReservation, TotalAmount) VALUES
(2,2,2,3,'07/10/2024','07/15/2024',200.00,'06/22/2024',1000.00);
INSERT INTO Reservations (ReservationID, CustomerID, HotelID, RoomType, StartDate, EndDate, Rate, DateOfReservation, Tota
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions