0% found this document useful (0 votes)
44 views

Data and Tables

The document contains SQL commands to create tables for an entity relationship diagram for a hotel booking system. The tables created are for customers, rooms, hotels, transactions, room rates, services, and bookings. Sample data is inserted into the customer, room, and transaction tables. Foreign key constraints are defined to link the tables together.

Uploaded by

Asad Ul Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Data and Tables

The document contains SQL commands to create tables for an entity relationship diagram for a hotel booking system. The tables created are for customers, rooms, hotels, transactions, room rates, services, and bookings. Sample data is inserted into the customer, room, and transaction tables. Foreign key constraints are defined to link the tables together.

Uploaded by

Asad Ul Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

E-R Diagram

3
SQL Commands
drop table transaction cascade constraints;
drop table hotel cascade constraints;
drop table room cascade constraints;
drop table customer cascade constraints;
drop table customer booking constraints;
drop table rate cascade constraints;
drop table service cascade constraints;

create table customer


(
customer_name varchar(50),
customer_address varchar(50),
customer_phone number,
customer_id number,
customer_payment_type varchar(20)
primary key (customer_id));

Create table room (


room_id number,
room_availability varchar(3),
room_type varchar (10),
room_rate number,
room_number number,
primary key (room_id, room_availability));

Create table hotel


(

4
hotel_id number,
hotel_name varchar(50),
hotel_address varchar(50),
hotel_phone number,
room_availability varchar(3) foreign key references room (room_availability),
primary key (hotel_id);

create table transaction (


transaction_id number,
payment_type varchar(30),
transaction_total number,
transaction_date date,
booking_id number,
Room_rate_id number,
Service_id number,
primary key(transaction_id),
foreign key (room_rate_amount) references room_rate (room_rate_id),
foreign key(booking_id) references booking (booking_id),
foreign key(service_id) references service (service_id),
);

Create table room_rate (


room_rate_id number,
room_rate_amount number,
primary key (room_rate_id));

Create table service (


Service_id,

5
Service_type,
Service_rate
Primary key (service_id);

Create table booking


(
booking_id number,
customer_id number,
hotel_id number,
Room_id number,
Transaction_id number,
Arrival_date date,
Departure_date date,
Primary key (booking_id),
Foreign key (customer_id) references customer (customer_id),
Foreign key (hotel_id) references hotel (hotel_id),
Foreign key (transaction_id) references transaction (transaction_id),
Foreign key (room_id) references room (room_id));

INSERT INTO CUSTOMER VALUES ('Cecilia Chapman', '711 Nulla St', 2575637401, 001);
INSERT INTO CUSTOMER VALUES ('Theodore Lowe', 'Apt 867 Sit Rd. Azusa New York
39531', 7931516230, 002);
INSERT INTO CUSTOMER VALUES ('Aaron Hawkins', '5587 Nunc. Avenue Erie Rhode
Island 24975', 6696634518, 003);
INSERT INTO CUSTOMER VALUES ('Keefe Sellers', '347-7666 Iaculis St. Woodruff SC
49854', 468353-2641, 004);

INSERT INTO ROOM VALUES (108, 'Standard', 1, 'yes');


INSERT INTO ROOM VALUES (115, 'Deluxe', 2, 'no');

6
INSERT INTO ROOM VALUES (205, 'Suite', 3, 'no');
INSERT INTO ROOM VALUES (215, 'Suite', 3, 'yes');

INSERT INTO TRANSPORTATION VALUES (003, 'Air Canada', DATE '2019-12-17', DATE
'2019-12-25', 'Hilton Baltimore', 'BWI Airport');
INSERT INTO TRANSPORTATION VALUES (001, 'Lufthansa', DATE '2019-08-09', DATE
'2019-02-12', 'HILTON BROOKLYN NEW YORK', 'JFK Airport');
INSERT INTO TRANSPORTATION VALUES (004, 'Delta airlines', DATE '2019-09-05', DATE
'2019-09-07', 'HILTON LONG ISLAND/HUNTINGTON', 'Long Island MacArthur Airport');
INSERT INTO TRANSPORTATION VALUES (002, 'Southwest', DATE '2019-11-18', DATE
'2019-11-24', 'HILTON PARSIPPANY', 'Newark Liberty International Airport');

INSERT INTO TRANSACTION VALUES (4569873, 'Credit Card Visa', 750, DATE
'2019-06-22', 003, 205);
INSERT INTO TRANSACTION VALUES (4564523, 'Credit Card Mastercard', '670', DATE
'2019-05-29', 001, 108);
INSERT INTO TRANSACTION VALUES (4568762, 'Credit Card Visa', '450', DATE
'2019-05-22', 002, 115);
INSERT INTO TRANSACTION VALUES (4561258, 'Credit Card Amex', '490', DATE
'2019-06-20', 004, 215);

You might also like