-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNancyYoon-HotelDB.sql
63 lines (56 loc) · 1.6 KB
/
NancyYoon-HotelDB.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
DROP DATABASE IF EXISTS HotelReservation;
-- CREATE DATABASE HotelReservation;
CREATE DATABASE IF NOT EXISTS HotelReservation;
USE HotelReservation;
CREATE TABLE Amenity (
AmenityID INT PRIMARY KEY AUTO_INCREMENT,
Name CHAR(50) NOT NULL
);
CREATE TABLE RoomType (
RoomTypeID INT PRIMARY KEY AUTO_INCREMENT,
Type CHAR(10) NOT NULL,
StandardOccupancy INT NOT NULL,
MaximumOccupancy INT NOT NULL,
BasePrice DECIMAL(5, 2) NOT NULL,
ExtraPersonPrice DECIMAL(4, 2) NULL
);
CREATE TABLE Room (
RoomNumber INT PRIMARY KEY,
ADAAccessible BOOL NOT NULL,
RoomTypeID INT NOT NULL,
FOREIGN KEY fk_Room_RoomType (RoomTypeID)
REFERENCES RoomType(RoomTypeID)
);
CREATE TABLE RoomAmenity (
RoomNumber INT NOT NULL,
AmenityID INT NOT NULL,
PRIMARY KEY pk_RoomAmenity (RoomNumber, AmenityID),
FOREIGN KEY fk_ARoomAmenity_Room (RoomNumber)
REFERENCES Room(RoomNumber),
FOREIGN KEY fk_RoomAmenity_Amenity (AmenityID)
REFERENCES Amenity(AmenityID)
);
CREATE TABLE Guest (
GuestID INT PRIMARY KEY AUTO_INCREMENT,
FirstName VARCHAR(25),
LastName VARCHAR(50),
Address VARCHAR(100),
City CHAR(25),
State CHAR(5),
Zip CHAR(10),
Phone CHAR(20)
);
CREATE TABLE Reservation (
ReservationID INT PRIMARY KEY,
RoomNumber INT NOT NULL,
FOREIGN KEY fk_Reservation_Room (RoomNumber)
REFERENCES Room(RoomNumber),
GuestID INT NOT NULL,
FOREIGN KEY fk_Reservation_Guest (GuestID)
REFERENCES Guest(GuestID),
Adult INT NOT NULL,
Children INT NOT NULL,
StartDate DATE NOT NULL,
EndDate DATE NOT NULL,
TotalRoomCost DECIMAL(20, 2)
);