You are on page 1of 57

FACULTY OF COMPUTING AND INFORMATION TECHNOLOGY

BACS1053 DATABASE MANAGEMENT

Assignment

Semester Jan 2021

Programme : Bachelor of Information Technology (Honours)


in Software Systems Development
Tutorial Group : 4
Date Submitted : 22/03/2021

Team member:

No Name (Block Letters) Registration No. Signature Mark

1 Benedict Yap Zheng-Yi 20WMR11830 Y ap

2 Gan Eng Kiat 20WMR12361 Gan

3 Tan Yong Jie 21WMR00167 J ie


FACULTY OF COMPUTING AND INFORMATION TECHNOLOGY

Plagiarism Statement and Guideline for Late Submission of Coursework

Read, complete, and sign this statement to be submitted with the written report.

We confirm that we have read and shall comply with all the terms and conditions of TAR
University College’s plagiarism policy.

We declare that this assignment is free from all forms of plagiarism and for all intents and
purposes is my own properly derived work.

Declaration Statement Acknowledged by

No Name (Block Letters) Registration Signature Date


No.
1 Benedict Yap Zheng-Yi 20WMR11830 Y ap 5/4/2021
2 Gan Eng Kiat 20WMR12361 Gan 5/4/2021
3 Tan Yong Jie 21WMR00167 J ie 5/4/2021
Assignment Assessment Form (CLO3)
Programme: RSD1( G4 ) Member Name: 1.Benedict Yap Zhengi-Yi, 2.Gan Eng Kiat, 3.Tan Yong Jie

Task Task Weightage Criteria 1 2 3 4 Comment


No. Descriptions
1 Develop 10% ● Include the required and relevant pairs of business rules.
Business rules ● All business rules must be clearly defined, precise, and reflect the policies
and procedures of the organization’s operational environment.
2 Develop ERD 10% ● Transform business rules to a relational database model correctly.
● Correct use of Crow’s Foot notations.
● Include all necessary entities, attribute & relationships.
3 Develop 10% ● Correct use of DBDL format as required
DBDL ● All required entities, attributes and relationships correctly shown
● Indicate Primary key and Foreign key clearly
4 Database 10% ● Correct tables, records and fields designed according to the ERD
Design developed.
20% 10% ● Enforcement of entity integrity rule & referential integrity rule
● Appropriate data types, default values and check constraints.
5 Records 10% ● Provide sufficient and quality data records
(Entries) ● Well-designed records for adequate and logical choices of queries to be
performed
6 Queries 6% ● Flexible query for variety of inputs. Clear & proper identification of
Design information needs.
30% 6% ● Apply Accept, Prompt and variable substitution in queries. Flexible
6% query to cater for variety of inputs, use of multiple tables.
● Apply Report Formatting features. Meaningful report handlings. Data
6%
values formatted accordingly.
6% ● Only SELECT statements.
7 Assignment 10% ● Comprehensive, clarity and completeness coverage
Report ● Quality of report presented
● Presentation and Q & A
Assignment Marks / 100
Content table

No. Declaration Page

1. Task 1: Develop Business Rules 1-2

2. Task 2: Entity Relationship Diagram 3

3. Task 3: Develop the Database Schema 4

4. Task 4: Create Database in Oracle 5-7


4.1 Customer table
4.2 Payment table
4.3 Booking table
4.4 Hall table
4.5 Seat table
4.6 Movie table
4.7 Movie schedule table
4.8 Booking detail table
4.9 Item table
4.10 Order detail table

5. Task 5: Create record 8-18


5.1 Customer record
5.2 Payment record
5.3 Booking record
5.4 Booking detail record
5.5 Seat record
5.6 Hall record
5.7 Movie schedule record
5.8 Movie record
5.9 Order detail record
5.10 Item record

6. Task 6: Create Queries


6.1: Benedict Yap Zheng-Yi 19 - 28
6.1.1: Query 1:Display customer make a booking at age between 18 to 28
6.1.2: Query 2:Display customer details search based on customer name
selected
6.1.3: Query 3:Display the customer have special festival discount details
6.1.4: Query 4:Display the total amount have earn based on date selected
6.1.5: Query 5:Display the top 10 sales of the movie

6.2: Tan Yong Jie 29 - 38


6.2.1: Query 1: Display customer booking detail based on customer name
6.2.2: Query 2: Display the movie schedule based on movie name
6.2.3: Query 3: Display the movie description
6.2.4: Query 4: Display date of booking
6.2.5: Query 5: Display Item description for each item
6.3: Gan Eng Kiat 39 - 51
6.3.1: Query 1: Display how many couple seats have been booked.
6.3.2: Query 2: The quantity of item customer ordered
6.3.3 Query 3: Quantity of customer booking on a certain date.
6.3.4: Query 4: Display the movie customer likes most.
6.3.5: Query 5: Payment method the customer used.
Task 1: Develop Business Rules

Business rules for the Dragon Cinema used in the online booking system:

1. When the customer wants to make a purchased ticket in the cinema, they can choose to purchase a
ticket at the counter or book the ticket online on the cinema website. The customer would need to
provide their details which will be stored for future use.

2. A customer can have one or many bookings but a booking can only for one and only one customer.
(one to many)

3. The payment must contain credit card details and payment amount while the customer must provide
their name and contact number.

4. The payment can be paid for one or many bookings at a time and each of the bookings can only
pay by one and only one payment. (one to many)

5. One booking can consist of one or many seats and one seat can exist in one or many bookings.
(many to many)

6. There are many halls in the cinema. There are many seats inside each cinema hall and customers
can pick the seat type they want. One hall can have one or many seats and one seat only can have
one and only one hall. (one to many)

7. A seat has a recommended price, which depends on the category.

8. A movie can have one or many movie schedules and a movie schedule can only for one and only
one movie.

9. The seat is divided into two types. Which are the standard seat and a couple seat with the price
RM14 and RM22.

10. The cinema has sold a lot of items like food, drink and toys.

11. One booking can consist of one or many items and one item can exist in one or many bookings.
(many to many)

1
Business process:

1. Customer service can investigate customer complaints.

2. The system will send the booking confirmation email to the customer after a successful payment.
QR code will be sent with a confirmation email.

3. Customers need to scan the QR code before entering the hall.

Assumption:

1. Customers are able to check their booking status from their individual account.

2. Customers can send feedback through an online website and application.

3. Customers cannot cancel their booking after they already make the payment.

2
Task 2: Entity-Relationship Diagram (ERD)

3
Task 3: Develop The Database Schema

CUSTOMER (CUST_ID, CUST_NAME, IC_NO, CUST_CONTACT, EMAIL, GENDER,


CUST_DOB)

payment (payment_ID, AMOUNT, payment_METHOD, payment_DATE)

BOOKING (BOOKING_ID, BOOKING_DATE, CUST_ID*, payment_ID*)

BOOKING_DETAILS (BOOKING_ID*, SCHEDULE_ID*, SEAT_ID*, PRICE)

SEAT (SEAT_ID, SEAT_CATECORY, HALL_ID*)

HALL (HALL_ID, HALL_CAPACITY, HALL_STATUS, )

MOVIE_SCHEDULE (SCHEDULE_ID, TIME _START, TIME_END, MOVIE_ID*, HALL_ID*)

MOVIE (MOBIE_ID, MOVIE_NAME, MOVIE_LANGUAGE, MOVIE_DESC)

ORDER DETAIL (ITEM_ID*, BOOKING_ID*, payment_ID*, QUANTITY, ITEM_PRICE)

ITEM (ITEM_ID, ITEM_DESC, CATEGORY, UNIT_PRICE)

4
Task 4: Create database table in Oracle

4.1 Customer table


create table customer (
cust_id varchar(8) not null,
cust_name varchar(30) not null,
ic_no varchar(12) not null,
cust_contact varchar(13),
email varchar(30),
cust_dob date,
gender char(1),
Primary key (cust_id),
constraint chk_email check (REGEXP_LIKE(email,'^[a-zA-Z]\w+@(\S+)$')),
constraint chk_gender check (UPPER(gender) in ('M','F'))
);

4.2 Payment table


create table payment (
payment_id varchar(6) not null,
amount number,
payment_method varchar(15),
payment_date date,
Primary key (payment_id),
constraint chk_payment_method check (payment_method IN ('CREDIT CARD','Touch n
GO','BOOST','GRAB PAY'))
);

4.3 Booking table


create table booking (
booking_id varchar(6) not null,
booking_date date,
cust_id varchar(5) not null,
payment_id varchar(6) not null,
Primary key (booking_id),
Foreign key (cust_id) references customer (cust_id),
Foreign key (payment_id) references payment (payment_id)
);

4.4 Hall table


create table hall (
hall_id varchar(5) not null,
hall_capacity number,
hall_status varchar(10),
Primary key (hall_id),
Constraint chk_hall_status check (UPPER(hall_status) in ('ACTIVE','INACTIVE'))
);

5
4.5 Seat table
create table seat (
seat_id varchar(10) not null,
seat_category varchar(10),
hall_id varchar(5) not null,
Primary key (seat_id),
Foreign key (hall_id) references hall (hall_id),
constraint chk_seat_category check (seat_category IN ('Standard','Couple'))
);

4.6 Movie table


create table movie (
movie_id varchar(5) not null,
movie_name varchar(30),
movie_language varchar(15),
movie_desc varchar(10),
Primary key (movie_id)
);

4.7 Movie schedule table


create table movie_schedule (
schedule_id varchar(6) not null,
time_start varchar(11),
time_end varchar(11),
movie_id varchar(5) not null,
hall_id varchar(5) not null,
Primary key (schedule_id),
Foreign key (movie_id) references movie (movie_id),
Foreign key (hall_id) references hall (hall_id)
);

4.8 Booking detail table


create table booking_detail (
booking_id varchar(6) not null,
schedule_id varchar(6) not null,
seat_id varchar(10) not null,
price number,
Primary key (booking_id, schedule_id, seat_id),
Foreign key (booking_id) references booking (booking_id),
Foreign key (schedule_id) references movie_schedule (schedule_id),
Foreign key (seat_id) references seat (seat_id)
);

6
4.9 Item table
create table item (
item_id varchar(5) not null,
item_desc varchar(20),
category varchar(10),
unit_price number,
Primary key (item_id),
constraint chk_category check (category IN('Food','Beverages','Toy'))
);

5.0 Order detail table


create table order_detail (
booking_id varchar(6) not null,
item_id varchar(5) not null,
payment_id varchar(6) not null,
item_price number,
quantity number,
Primary key (booking_id, item_id, payment_id),
Foreign key (booking_id) references booking (booking_id),
Foreign key (item_id) references item (item_id),
Foreign key (payment_id) references payment (payment_id)
);

7
Task 5: Create records

5.1 Customer record

INSERT INTO customer VALUES ('C0001','Aloha Chickenist','990905148188','016-


0212304','Mimilaidiusni@outlook.com','05-Sep-1999','F');

INSERT INTO customer VALUES ('C0002','Benjamin Zimmerman','981123100071','016-


8119462','velit@gmail.com','23-Nov-1998','M');

INSERT INTO customer VALUES ('C0003','Bruno Hopper','830306014575','010-


5244456','amet@hotmail.com','06-Mar-1983','M');

INSERT INTO customer VALUES ('C0004','Baker Greer','321223130534','015-


4208885','neet@gmail.com','23-Dec-1932','F');

INSERT INTO customer VALUES ('C0005','Alyssa Oneill','011001146080','015-


1149858','laoreet@hotmail.com','01-Oct-2001','F');

INSERT INTO customer VALUES ('C0006','Maya Rodriquez','770401124703','019-


3520038','at@hotmail.com','01-Apr-1977','M');

INSERT INTO customer VALUES ('C0007','Connor Ballard','000309022832','014-


8400644','vulputate@hotmail.com','09-May-2000','F');

INSERT INTO customer VALUES ('C0008','Xandra Garza','740924102705','016-


6821411','scelerisque@hotmail.com','24-Sep-1974','M');

INSERT INTO customer VALUES ('C0009','Kieran Riley','990516055545','010-


3804434','etMagne@gmail.com','16-May-1999','M');

INSERT INTO customer VALUES ('C0010','Ivana Cote','030226062563','017-


5738182','taciti@hotmail.uk','26-Feb-2003','M');

5.2 Payment record

8
INSERT INTO payment VALUES ('PM0001', 65.20, 'CREDIT CARD', '1-Jan-2021');

INSERT INTO payment VALUES ('PM0002', 100.80, 'Touch n GO', '4-Jan-2021');

INSERT INTO payment VALUES ('PM0003', 77.60, 'BOOST', '5-Jan-2021');

INSERT INTO payment VALUES ('PM0004', 56.42, 'GRAB PAY', '6-Jan-2021');

INSERT INTO payment VALUES ('PM0005', 87.42, 'CREDIT CARD', '7-Jan-2021');

INSERT INTO payment VALUES ('PM0006', 78.04, 'Touch n GO', '8-Jan-2021');

INSERT INTO payment VALUES ('PM0007', 77.02, 'BOOST', '9-Jan-2021');

INSERT INTO payment VALUES ('PM0008', 76.89, 'GRAB PAY', '10-Jan-2021');

INSERT INTO payment VALUES ('PM0009', 130.25, 'CREDIT CARD', '11-Jan-2021');

INSERT INTO payment VALUES ('PM0010', 88.95, 'Touch n GO', '12-Jan-2021');

5.3 Booking record


INSERT INTO booking VALUES ('BK0001', '1-Jan-2021', 'C0001', 'PM0001');

INSERT INTO booking VALUES ('BK0002', '4-Jan-2021', 'C0002', 'PM0002');

INSERT INTO booking VALUES ('BK0003', '5-Jan-2021', 'C0003', 'PM0003');

INSERT INTO booking VALUES ('BK0004', '6-Jan-2021', 'C0004', 'PM0004');

INSERT INTO booking VALUES ('BK0005', '7-Jan-2021', 'C0005', 'PM0005');

INSERT INTO booking VALUES ('BK0006', '8-Jan-2021', 'C0006', 'PM0006');

INSERT INTO booking VALUES ('BK0007', '9-Jan-2021', 'C0007', 'PM0007');

INSERT INTO booking VALUES ('BK0008', '10-Jan-2021', 'C0008', 'PM0008');

INSERT INTO booking VALUES ('BK0009', '11-Jan-2021', 'C0009', 'PM0009');

INSERT INTO booking VALUES ('BK0010', '12-Jan-2021', 'C0010', 'PM0010');

5.4 Booking detail record

9
INSERT INTO booking_detail VALUES ('BK0001', 'MS0006', 'H06R03S01', 14.00);

INSERT INTO booking_detail VALUES ('BK0001', 'MS0006', 'H06R03S02', 14.00);

INSERT INTO booking_detail VALUES ('BK0001', 'MS0006', 'H06R03S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0002', 'MS0002', 'H02R10S03', 22.00);

INSERT INTO booking_detail VALUES ('BK0002', 'MS0002', 'H02R10S04', 22.00);

INSERT INTO booking_detail VALUES ('BK0002', 'MS0002', 'H02R10S05', 22.00);

INSERT INTO booking_detail VALUES ('BK0003', 'MS0005', 'H05R10S08', 22.00);

INSERT INTO booking_detail VALUES ('BK0003', 'MS0005', 'H05R10S09', 22.00);

INSERT INTO booking_detail VALUES ('BK0003', 'MS0005', 'H05R10S10', 22.00);

INSERT INTO booking_detail VALUES ('BK0004', 'MS0002', 'H02R04S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0004', 'MS0002', 'H02R04S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0004', 'MS0002', 'H02R04S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0005', 'MS0012', 'H12R06S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0005', 'MS0012', 'H12R06S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0005', 'MS0012', 'H12R06S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0006', 'MS0008', 'H08R03S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0006', 'MS0008', 'H08R03S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0006', 'MS0008', 'H08R03S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0007', 'MS0001', 'H01R02S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0007', 'MS0001', 'H01R02S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0007', 'MS0001', 'H01R02S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0008', 'MS0004', 'H04R01S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0008', 'MS0004', 'H04R01S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0008', 'MS0004', 'H04R01S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0009', 'MS0007', 'H07R02S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0009', 'MS0007', 'H07R02S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0009', 'MS0007', 'H07R02S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0010', 'MS0004', 'H04R01S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0010', 'MS0004', 'H04R01S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0010', 'MS0004', 'H04R01S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0011', 'MS0010', 'H10R02S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0011', 'MS0010', 'H10R02S06', 14.00);

10
INSERT INTO booking_detail VALUES ('BK0011', 'MS0010', 'H10R02S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0012', 'MS0002', 'H02R05S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0012', 'MS0002', 'H02R05S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0012', 'MS0002', 'H02R05S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0013', 'MS0014', 'H14R01S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0013', 'MS0014', 'H14R01S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0013', 'MS0014', 'H14R01S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0014', 'MS0013', 'H13R02S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0014', 'MS0013', 'H13R02S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0014', 'MS0013', 'H13R02S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0015', 'MS0013', 'H13R03S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0015', 'MS0013', 'H13R03S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0015', 'MS0013', 'H13R03S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0016', 'MS0005', 'H05R03S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0016', 'MS0005', 'H05R03S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0016', 'MS0005', 'H05R03S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0017', 'MS0005', 'H05R08S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0017', 'MS0005', 'H05R08S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0017', 'MS0005', 'H05R08S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0018', 'MS0009', 'H09R03S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0018', 'MS0009', 'H09R03S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0018', 'MS0009', 'H09R03S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0019', 'MS0013', 'H13R03S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0019', 'MS0013', 'H13R03S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0019', 'MS0013', 'H13R03S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0020', 'MS0012', 'H12R07S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0020', 'MS0012', 'H12R07S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0020', 'MS0012', 'H12R07S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0021', 'MS0014', 'H14R02S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0021', 'MS0014', 'H14R02S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0021', 'MS0014', 'H14R02S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0022', 'MS0011', 'H11R03S01', 14.00);

11
INSERT INTO booking_detail VALUES ('BK0022', 'MS0011', 'H11R03S02', 14.00);

INSERT INTO booking_detail VALUES ('BK0022', 'MS0011', 'H11R03S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0023', 'MS0012', 'H12R06S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0023', 'MS0012', 'H12R06S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0023', 'MS0012', 'H12R06S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0024', 'MS0005', 'H05R02S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0024', 'MS0005', 'H05R02S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0024', 'MS0005', 'H05R02S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0025', 'MS0014', 'H14R05S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0025', 'MS0014', 'H14R05S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0025', 'MS0014', 'H14R05S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0026', 'MS0010', 'H10R02S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0026', 'MS0010', 'H10R02S07', 14.00);

INSERT INTO booking_detail VALUES ('BK0026', 'MS0010', 'H10R02S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0027', 'MS0001', 'H01R02S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0027', 'MS0001', 'H01R02S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0027', 'MS0001', 'H01R02S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0028', 'MS0002', 'H02R09S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0028', 'MS0002', 'H02R09S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0028', 'MS0002', 'H02R09S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0029', 'MS0011', 'H11R02S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0029', 'MS0011', 'H11R02S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0029', 'MS0011', 'H11R02S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0030', 'MS0008', 'H08R07S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0030', 'MS0008', 'H08R07S04', 14.00);

INSERT INTO booking_detail VALUES ('BK0030', 'MS0008', 'H08R07S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0031', 'MS0006', 'H06R02S01', 14.00);

INSERT INTO booking_detail VALUES ('BK0031', 'MS0006', 'H06R02S02', 14.00);

INSERT INTO booking_detail VALUES ('BK0031', 'MS0006', 'H06R02S03', 14.00);

INSERT INTO booking_detail VALUES ('BK0032', 'MS0010', 'H10R07S05', 14.00);

INSERT INTO booking_detail VALUES ('BK0032', 'MS0010', 'H10R07S06', 14.00);

INSERT INTO booking_detail VALUES ('BK0032', 'MS0010', 'H10R07S07', 14.00);

12
INSERT INTO booking_detail VALUES ('BK0033', 'MS0007', 'H07R03S08', 14.00);

INSERT INTO booking_detail VALUES ('BK0033', 'MS0007', 'H07R03S09', 14.00);

INSERT INTO booking_detail VALUES ('BK0033', 'MS0007', 'H07R03S10', 14.00);

INSERT INTO booking_detail VALUES ('BK0034', 'MS0001', 'H01R03S04', 14.00);

5.5 Seat record


INSERT INTO seat VALUES ('H01R01S01', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S02', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S03', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S04', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S05', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S06', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S07', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S08', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S09', 'Standard', 'H001');

INSERT INTO seat VALUES ('H01R01S10', 'Standard', 'H001');

5.6 Hall record


INSERT INTO hall VALUES ('H001',100,'ACTIVE');

INSERT INTO hall VALUES ('H002',100,'ACTIVE');

INSERT INTO hall VALUES ('H003',100,'ACTIVE');

INSERT INTO hall VALUES ('H004',100,'ACTIVE');

INSERT INTO hall VALUES ('H005',100,'ACTIVE');

INSERT INTO hall VALUES ('H006',100,'ACTIVE');

INSERT INTO hall VALUES ('H007',100,'ACTIVE');

INSERT INTO hall VALUES ('H008',100,'ACTIVE');

INSERT INTO hall VALUES ('H009',100,'ACTIVE');

INSERT INTO hall VALUES ('H010',100,'ACTIVE');

13
5.7 Movie schedule record
INSERT INTO movie_schedule VALUES ('MS0001','01:00 PM','03:30 PM','M0001','H001');

INSERT INTO movie_schedule VALUES ('MS0002','12:00 PM','14:30 PM','M0002','H002');

INSERT INTO movie_schedule VALUES ('MS0003','10:00 AM','12:30 PM','M0003','H003');

INSERT INTO movie_schedule VALUES ('MS0004','04:00 PM','06:30 PM','M0004','H004');

INSERT INTO movie_schedule VALUES ('MS0005','11:00 AM','01:30 PM','M0005','H005');

INSERT INTO movie_schedule VALUES ('MS0006','08:00 AM','10:30 PM','M0006','H006');

INSERT INTO movie_schedule VALUES ('MS0007','09:00 AM','11:00 PM','M0007','H007');

INSERT INTO movie_schedule VALUES ('MS0008','09:00 PM','11:30 PM','M0008','H008');

INSERT INTO movie_schedule VALUES ('MS0009','10:00 PM','12:00 AM','M0009','H009');

INSERT INTO movie_schedule VALUES ('MS0010','12:00 PM','01:30 PM','M0010','H010');

5.8 Movie record


INSERT INTO movie VALUES ('M0001','Monster Hunter','English','Action');

INSERT INTO movie VALUES ('M0002','Avengers: Endgame','English','Action');

INSERT INTO movie VALUES ('M0003','Worden Women','English','Action');

INSERT INTO movie VALUES ('M0004','King Kong','Chinese','Action');

INSERT INTO movie VALUES ('M0005','Aliens','English','Horror');

INSERT INTO movie VALUES ('M0006','The Fast and Furious' ,'English','Racing');

INSERT INTO movie VALUES ('M0007','Cars','English','Racing');

INSERT INTO movie VALUES ('M0008','Ip Man','Chinese','Action');

INSERT INTO movie VALUES ('M0009','Titanic','English','Drama');

INSERT INTO movie VALUES ('M0010','Spirited Away','Japanese','Action');

INSERT INTO movie VALUES ('M0011','Demon Slayer: Mugen Train','Japanese','Action');

INSERT INTO movie VALUES ('M0012','The Witch','English','Horror');

INSERT INTO movie VALUES ('M0013','New of the World','Chinese','Drama');

INSERT INTO movie VALUES ('M0014','Train to Busan','Korean','Horror');

INSERT INTO movie VALUES ('M0015','Spiderman','English','Action');

14
5.9 Order detail record
INSERT INTO order_detail VALUES ('BK0001', 'IF001', 'PM0001', 2, 11.60);

INSERT INTO order_detail VALUES ('BK0002', 'IF001', 'PM0002', 3, 11.60);

INSERT INTO order_detail VALUES ('BK0003', 'IF001', 'PM0003', 1, 11.60);

INSERT INTO order_detail VALUES ('BK0004', 'IF002', 'PM0004', 1, 14.42);

INSERT INTO order_detail VALUES ('BK0005', 'IF003', 'PM0005', 3, 15.14);

INSERT INTO order_detail VALUES ('BK0006', 'IF004', 'PM0006', 2, 18.02);

INSERT INTO order_detail VALUES ('BK0007', 'IF005', 'PM0007', 2, 17.51);

INSERT INTO order_detail VALUES ('BK0008', 'IF006', 'PM0008', 3, 11.63);

INSERT INTO order_detail VALUES ('BK0009', 'IF007', 'PM0009', 5, 17.62);

INSERT INTO order_detail VALUES ('BK0010', 'IF008', 'PM0010', 3, 15.65);

INSERT INTO order_detail VALUES ('BK0011', 'IF009', 'PM0011', 2, 12.62);

INSERT INTO order_detail VALUES ('BK0012', 'IF010', 'PM0012', 3, 13.20);

INSERT INTO order_detail VALUES ('BK0013', 'IF010', 'PM0013', 1, 13.20);

INSERT INTO order_detail VALUES ('BK0014', 'IF010', 'PM0014', 4, 13.20);

INSERT INTO order_detail VALUES ('BK0015', 'IF011', 'PM0015', 2, 15.39);

INSERT INTO order_detail VALUES ('BK0016', 'IF012', 'PM0016', 1, 19.26);

INSERT INTO order_detail VALUES ('BK0017', 'IF013', 'PM0017', 3, 13.50);

INSERT INTO order_detail VALUES ('BK0018', 'IF014', 'PM0018', 3, 18.69);

INSERT INTO order_detail VALUES ('BK0019', 'IF015', 'PM0019', 2, 17.21);

INSERT INTO order_detail VALUES ('BK0020', 'IF016', 'PM0020', 1, 17.75);

INSERT INTO order_detail VALUES ('BK0021', 'IF017', 'PM0021', 2, 13.01);

INSERT INTO order_detail VALUES ('BK0022', 'IF018', 'PM0022', 2, 18.77);

INSERT INTO order_detail VALUES ('BK0023', 'IF019', 'PM0023', 1, 15.36);

INSERT INTO order_detail VALUES ('BK0024', 'IF020', 'PM0024', 3, 17.10);

INSERT INTO order_detail VALUES ('BK0025', 'IF020', 'PM0025', 1, 17.10);

INSERT INTO order_detail VALUES ('BK0026', 'IF020', 'PM0026', 2, 17.10);

INSERT INTO order_detail VALUES ('BK0027', 'IF021', 'PM0027', 4, 12.34);

INSERT INTO order_detail VALUES ('BK0028', 'IF021', 'PM0028', 1, 12.34);

INSERT INTO order_detail VALUES ('BK0029', 'IF021', 'PM0029', 5, 12.34);

INSERT INTO order_detail VALUES ('BK0030', 'IF022', 'PM0030', 2, 12.53);

INSERT INTO order_detail VALUES ('BK0031', 'IF023', 'PM0031', 3, 10.41);

15
INSERT INTO order_detail VALUES ('BK0032', 'IF024', 'PM0032', 1, 12.23);

INSERT INTO order_detail VALUES ('BK0033', 'IF025', 'PM0033', 4, 18.67);

INSERT INTO order_detail VALUES ('BK0034', 'IF026', 'PM0034', 2, 19.91);

INSERT INTO order_detail VALUES ('BK0035', 'IF027', 'PM0035', 5, 13.20);

INSERT INTO order_detail VALUES ('BK0036', 'IF028', 'PM0036', 3, 13.16);

INSERT INTO order_detail VALUES ('BK0037', 'IF029', 'PM0037', 5, 16.87);

INSERT INTO order_detail VALUES ('BK0038', 'IF030', 'PM0038', 2, 10.10);

INSERT INTO order_detail VALUES ('BK0039', 'IF030', 'PM0039', 1, 10.10);

INSERT INTO order_detail VALUES ('BK0040', 'IF030', 'PM0040', 1, 10.10);

INSERT INTO order_detail VALUES ('BK0041', 'IB001', 'PM0041', 1, 9.66);

INSERT INTO order_detail VALUES ('BK0042', 'IB002', 'PM0042', 2, 7.73);

INSERT INTO order_detail VALUES ('BK0043', 'IB003', 'PM0043', 1, 9.20);

INSERT INTO order_detail VALUES ('BK0044', 'IB004', 'PM0044', 4, 8.24);

INSERT INTO order_detail VALUES ('BK0045', 'IB005', 'PM0045', 3, 5.93);

INSERT INTO order_detail VALUES ('BK0046', 'IB006', 'PM0046', 2, 5.99);

INSERT INTO order_detail VALUES ('BK0047', 'IB007', 'PM0047', 2, 7.98);

INSERT INTO order_detail VALUES ('BK0048', 'IB008', 'PM0048', 3, 8.25);

INSERT INTO order_detail VALUES ('BK0049', 'IB009', 'PM0049', 3, 6.23);

INSERT INTO order_detail VALUES ('BK0050', 'IB010', 'PM0050', 2, 6.30);

INSERT INTO order_detail VALUES ('BK0051', 'IB010', 'PM0051', 1, 6.30);

INSERT INTO order_detail VALUES ('BK0052', 'IB010', 'PM0052', 1, 6.30);

INSERT INTO order_detail VALUES ('BK0053', 'IB010', 'PM0053', 2, 6.30);

INSERT INTO order_detail VALUES ('BK0054', 'IB011', 'PM0054', 3, 9.42);

INSERT INTO order_detail VALUES ('BK0055', 'IB012', 'PM0055', 3, 6.68);

INSERT INTO order_detail VALUES ('BK0056', 'IB013', 'PM0056', 4, 6.18);

INSERT INTO order_detail VALUES ('BK0057', 'IB014', 'PM0057', 2, 6.16);

INSERT INTO order_detail VALUES ('BK0058', 'IB015', 'PM0058', 5, 5.19);

INSERT INTO order_detail VALUES ('BK0059', 'IB016', 'PM0059', 3, 6.23);

INSERT INTO order_detail VALUES ('BK0060', 'IB017', 'PM0060', 2, 8.51);

INSERT INTO order_detail VALUES ('BK0061', 'IB018', 'PM0061', 2, 6.55);

INSERT INTO order_detail VALUES ('BK0062', 'IB019', 'PM0062', 5, 8.73);

INSERT INTO order_detail VALUES ('BK0063', 'IB020', 'PM0063', 2, 7.72);

16
INSERT INTO order_detail VALUES ('BK0064', 'IB020', 'PM0064', 4, 7.72);

INSERT INTO order_detail VALUES ('BK0065', 'IB020', 'PM0065', 2, 7.72);

INSERT INTO order_detail VALUES ('BK0066', 'IB020', 'PM0066', 1, 7.72);

INSERT INTO order_detail VALUES ('BK0067', 'IB021', 'PM0067', 4, 6.04);

INSERT INTO order_detail VALUES ('BK0068', 'IB022', 'PM0068', 2, 6.27);

INSERT INTO order_detail VALUES ('BK0069', 'IB023', 'PM0069', 5, 5.63);

INSERT INTO order_detail VALUES ('BK0070', 'IB024', 'PM0070', 1, 7.52);

INSERT INTO order_detail VALUES ('BK0071', 'IB025', 'PM0071', 1, 7.90);

INSERT INTO order_detail VALUES ('BK0072', 'IB026', 'PM0072', 5, 8.10);

INSERT INTO order_detail VALUES ('BK0073', 'IB027', 'PM0073', 4, 9.97);

INSERT INTO order_detail VALUES ('BK0074', 'IB028', 'PM0074', 2, 9.46);

INSERT INTO order_detail VALUES ('BK0075', 'IB029', 'PM0075', 3, 6.81);

INSERT INTO order_detail VALUES ('BK0076', 'IB030', 'PM0076', 2, 7.92);

INSERT INTO order_detail VALUES ('BK0077', 'IB030', 'PM0077', 3, 7.92);

INSERT INTO order_detail VALUES ('BK0078', 'IB030', 'PM0078', 2, 7.92);

INSERT INTO order_detail VALUES ('BK0079', 'IB030', 'PM0079', 5, 7.92);

INSERT INTO order_detail VALUES ('BK0080', 'IT001', 'PM0080', 1, 12.03);

INSERT INTO order_detail VALUES ('BK0081', 'IT002', 'PM0081', 1, 13.47);

INSERT INTO order_detail VALUES ('BK0082', 'IT003', 'PM0082', 1, 11.22);

INSERT INTO order_detail VALUES ('BK0083', 'IT004', 'PM0083', 2, 13.74);

INSERT INTO order_detail VALUES ('BK0084', 'IT005', 'PM0084', 3, 13.75);

INSERT INTO order_detail VALUES ('BK0085', 'IT006', 'PM0085', 1, 10.03);

INSERT INTO order_detail VALUES ('BK0086', 'IT007', 'PM0086', 1, 12.74);

INSERT INTO order_detail VALUES ('BK0087', 'IT008', 'PM0087', 2, 12.08);

INSERT INTO order_detail VALUES ('BK0088', 'IT009', 'PM0088', 5, 12.18);

INSERT INTO order_detail VALUES ('BK0089', 'IT010', 'PM0089', 2, 14.98);

INSERT INTO order_detail VALUES ('BK0090', 'IT011', 'PM0090', 5, 11.03);

INSERT INTO order_detail VALUES ('BK0091', 'IT012', 'PM0091', 4, 13.69);

INSERT INTO order_detail VALUES ('BK0092', 'IT013', 'PM0092', 1, 14.28);

INSERT INTO order_detail VALUES ('BK0093', 'IT014', 'PM0093', 2, 10.16);

INSERT INTO order_detail VALUES ('BK0094', 'IT015', 'PM0094', 1, 10.96);

INSERT INTO order_detail VALUES ('BK0095', 'IT016', 'PM0095', 1, 14.89);

17
INSERT INTO order_detail VALUES ('BK0096', 'IT017', 'PM0096', 1, 11.75);

INSERT INTO order_detail VALUES ('BK0097', 'IT018', 'PM0097', 1, 14.55);

INSERT INTO order_detail VALUES ('BK0098', 'IT019', 'PM0098', 3, 11.64);

INSERT INTO order_detail VALUES ('BK0099', 'IT020', 'PM0099', 2, 11.45);

INSERT INTO order_detail VALUES ('BK0100', 'IT021', 'PM0100', 1, 11.75);

5.10 Item record


INSERT INTO item VALUES ('IF001', 'Pakore', 'Food', 11.58);

INSERT INTO item VALUES ('IF002', 'Banana Biscuit', 'Food', 14.42);

INSERT INTO item VALUES ('IF003', 'Peanut Butter', 'Food', 15.14);

INSERT INTO item VALUES ('IF004', 'Cheeseburger', 'Food', 18.02);

INSERT INTO item VALUES ('IF005', 'Sandwich', 'Food', 17.51);

INSERT INTO item VALUES ('IF006', 'Banana', 'Food', 11.63);

INSERT INTO item VALUES ('IF007', 'Doughnut', 'Food', 17.62);

INSERT INTO item VALUES ('IF008', 'Potato Chips', 'Food', 15.65);

INSERT INTO item VALUES ('IF009', 'Salat', 'Food', 12.62);

INSERT INTO item VALUES ('IF010', 'Peanut Brown', 'Food', 13.20);

18
Task 6: Create Queries

6.1 Benedict Yap Zheng-Yi

6.1.1 Query 1: Display customer make a booking at the age between 18 and 28

Purpose: The purpose of this query is to let the user know how many young
adults have made a booking in the cinema. The user can use this query when
they need to check how many customers are young adults.

SQL Statement
DROP VIEW cust_booking_detail;

TTITLE CENTER 'Customer booking details between age 18 to 28'-


RIGHT 'Page:' FORMAT 999 SQL.PNO SKIP 2

CREATE VIEW cust_booking_detail as


SELECT c.cust_id,c.cust_name,c.gender,c.cust_dob,TRUNC((SYSDATE -
cust_dob)/365.25) AS Age,count(d.booking_id) AS Total_booking
FROM customer c,booking b,booking_detail d
WHERE b.booking_id = d.booking_id
AND b.cust_id = c.cust_id
AND TRUNC((SYSDATE -cust_dob)/365.25) BETWEEN 18 AND 28
GROUP BY c.cust_id,c.cust_name,c.gender,c.cust_dob
ORDER BY c.cust_id;

SET linesize 120


SET pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

COLUMN cust_id FORMAT A11 HEADING "Customer ID";


COLUMN cust_name FORMAT A20 HEADING "Customer Name";
COLUMN gender FORMAT A6 HEADING "Gender";
COLUMN cust_dob FORMAT A12 HEADING "Customer DOB";
COLUMN Total_booking FORMAT 9999999999999 HEADING "Total Booking";

CLEAR SCREEN
PROMPT 'Get customer who have make booking at age 18 and 28'
PROMPT
PROMPT

SELECT * FROM cust_booking_details;

19
Sample Output

20
6.1.2 Query 2: Display the customer details search based on the customer name selected

Purpose: The purpose of this query is to let the user search customer details by entering
the customer name. The user can use this query when the user wants to search
for specific customer details.

SQL Statement
DROP VIEW cust_detail;

CLEAR SCREEN
ACCEPT v_cust_name char format 'A20' PROMPT 'Enter customer name :'

TTITLE CENTER 'Customer details for '&v_cust_name-


RIGHT 'Page No: ' FORMAT 999 SQL.PNO SKIP 2

CREATE VIEW cust_detail AS


SELECT C.cust_id, C.cust_name, C.gender, count(D.booking_id) AS
Total,sum(amount) AS total_amount
FROM customer C,booking B,booking_detail D,payment P
WHERE C.cust_id = B.cust_id
AND B.booking_id = D.booking_id
AND P.payment_id = B.payment_id
AND lower(C.cust_name) like lower('%&v_cust_name%')
GROUP BY C.cust_id, C.cust_name, C.gender;

SET linesize 120


SET pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

COLUMN cust_id FORMAT A11 HEADING "Customer ID";


COLUMN cust_name FORMAT A20 HEADING "Customer Name";
COLUMN gender FORMAT A6 HEADING "Gender";
COLUMN total FORMAT 99 HEADING "Total Booking";
COLUMN total_amount FORMAT $9999.99 HEADING "Total Amount(RM)";

PROMPT 'Get customer details'


PROMPT
PROMPT

SELECT * FROM cust_detail;

21
Sample Output

22
6.1.3 Query 3: Display the customer have special festival discount details

Purpose: The purpose of this query is to let the user know the details about the customer
getting the special festival discount between 17-Oct-2023 to 24-Oct-2023. The
user can use this query when the user wants to check the discount price and
customer details who have booking by using the discount on 17-Oct-2023 to
24-Oct-2023.

SQL Statement
DROP VIEW discount_detail;

TTITLE CENTER 'Special festival discount details'-


RIGHT 'Page:' FORMAT 999 SQL.PNO SKIP 2

CREATE VIEW discount_detail AS


SELECT ROW_NUMBER()OVER(ORDER BY cust_name ASC) AS No, C.cust_name, C.gender,
C.cust_dob, B.booking_id, P.payment_id, P.amount,(P.amount*0.9) AS discount,
P.payment_Method, P.payment_date
FROM customer C,payment P,booking B, booking_detail D
WHERE c.cust_id = B.cust_id
AND P.payment_id = B.payment_id
AND B.booking_id = D.booking_id
AND payment_date BETWEEN '17-OCt-2023' AND '24-Oct-2023'
ORDER BY cust_name;

SET linesize 160


SET pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

COLUMN No FORMAT 999 HEADING "No.";


COLUMN cust_name FORMAT A20 HEADING "Customer Name";
COLUMN gender FORMAT A6 HEADING "Gender";
COLUMN cust_dob FORMAT A12 HEADING "Customer DOB";
COLUMN booking_id FORMAT A10 HEADING "Booking ID";
COLUMN payment_id FORMAT A10 HEADING "Payment ID";
COLUMN amount FORMAT $9999.99 HEADING "Total Payment(RM)";
COLUMN discount FORMAT $9999.99 HEADING "Discount Total(RM)";
COLUMN payment_method FORMAT A14 HEADING "Payment Method";
COLUMN payment_date FORMAT A12 HEADING "Payment Date";

CLEAR SCREEN
PROMPT 'Get customer who have get the special festival discount'
PROMPT
PROMPT

SELECT * FROM discount_detail;

Sample Output

23
6.1.4 Query 4: Display the total amount have been earn based on the date selected

24
Purpose: The purpose of this query is to let the user search the total amount details
have been earned by the date that has been selected. The user can use this
query when the user wants to search the total amount on a certain date

SQL Statement
CLEAR SCREEN
SET linesize 120
SET pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

-- 01-JUN-2021 & 30-JUN-2021


ACCEPT v_Start_Date CHAR FORMAT 'A11' PROMPT ' Enter the start date: '
ACCEPT v_End_Date CHAR FORMAT 'A11' PROMPT ' Enter the end date: '

COLUMN movie_id FORMAT A10 HEADING "Movie ID";


COLUMN movie_name FORMAT A30 HEADING "Movie Name";
COLUMN Qty FORMAT 999999999999 HEADING "QTY Booking";
COLUMN total_amount FORMAT $999.999.99 HEADING "Total Amount(RM)";

TTITLE CENTER 'Total amount detail for ' v_Start_Date ' to ' v_End_Date-
RIGHT 'Page No: ' FORMAT 999 SQL.PNO SKIP 2

SELECT M.movie_id,M.movie_name,count(D.booking_id) AS Qty,sum(amount) AS


total_amount
FROM booking B,booking_detail D, payment P,movie M, movie_schedule MS
WHERE B.booking_id = D.booking_id
AND P.payment_id = B.payment_id
AND M.movie_id = MS.movie_id
AND P.payment_date BETWEEN '&v_Start_Date' AND '&v_End_Date'
GROUP BY M.movie_name,M.movie_id;

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
TTITLE OFF

25
Sample Output

26
6.1.5 Query 5: Display the top 10 sales of the movie

Purpose: The purpose of this query is to let the user search the top 10 sales of the movie. The
user can use this query when wanting to search the top sales of the movie.

SQL statement
cl screen
SET linesize 120
SET pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

COLUMN row_number FORMAT 999 HEADING "No.";


COLUMN movie_name FORMAT A30 HEADING "Movie Name";
COLUMN movie_id FORMAT A10 HEADING "Movie ID";
COLUMN schedule_id FORMAT A15 HEADING "Movie Schedule";
COLUMN num FORMAT 99999999999 HEADING "Total sales";

TTITLE CENTER 'Top 10 sales of the movie'-


RIGHT 'Page:' FORMAT 999 SQL.PNO SKIP 2

SELECT *
From (SELECT ROW_NUMBER() OVER(ORDER BY count(booking_id) DESC) AS
row_number , M.movie_name, M.movie_id, MS.schedule_id,count (D.booking_id) AS num
From movie M, movie_schedule MS, booking_detail D
WHERE M.movie_id = MS.movie_id
AND MS.schedule_id = D.schedule_id
GROUP BY M.movie_name, M.movie_id, MS.schedule_id
ORDER BY num DESC)
WHERE ROWNUM <=10;

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
TTITLE OFF

27
Sample Output

28
6.2 Tan Yong Jie

6.2.1 Query 1: Display customer booking number

Purpose: The purpose of this query is to let the user know how many tickets the user has
purchased on the booking date. Users can use this query to check the seat price and the total price
with the specific name.

SQL Statement
SET linesize 120
SET pagesize 150
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

COLUMN cust_id FORMAT A12 HEADING "Customer ID ";


COLUMN cust_name FORMAT A20 HEADING "Customer Name";
COLUMN booking_date FORMAT A12 HEADING "Booking Date ";
COLUMN price FORMAT 999.99 HEADING "Price (RM) ";
COLUMN QTY FORMAT 999999 HEADING "Quantity";
COLUMN seat_category FORMAT A15 HEADING "Seat Category";
COLUMN total FORMAT 9999.99 HEADING "Total (RM)";

TTITLE CENTER 'Booking record for customer '-


RIGHT 'Page No:' FORMAT 999 SQL.PNO SKIP 2
BREAK ON cust_id ON cust_name ON booking_id ON booking_date ON payment_id ON
seat_category ON price SKIP 1
COMPUTE SUM label 'Total:' OF total ON cust_id SKIP 2

SELECT C.cust_id, C.cust_name, count(B.booking_id) AS number_of_booking


FROM customer C, booking B
WHERE C.cust_id = B.cust_id
GROUP BY C.cust_id, C.cust_name
ORDER BY C.cust_id;

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
TTITLE OFF

29
Sample Output

30
6.2.2 Query 2: Display the movie schedule based on movie name

Purpose: The purpose of this query is to allow the user to check the time of the movie and the
hall for the movie. Users can enter the name of the movie to know the start time and hall.

SQL Statement

SET linesize 100


SET pagesize 150
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

ACCEPT v_movie_name char format 'A30' PROMPT 'Enter Movie Name :'

COLUMN movie_id FORMAT A10 HEADING "Movie ID";


COLUMN movie_name FORMAT A30 HEADING "Movie name";
COLUMN schedule_id FORMAT A20 HEADING "Schedule ID";
COLUMN time_start FORMAT A11 HEADING "Start time";
COLUMN time_end FORMAT A11 HEADING "End time";
COLUMN hall_id FORMAT 99999 HEADING "Hall ID";

TTITLE CENTER 'Movie Schedule for '&v_movie_name-


RIGHT 'Page No:' FORMAT 999 SQL.PNO SKIP 2
BREAK ON movie_name SKIP 2 ON movie_id

SELECT B.movie_id, B.movie_name, M.schedule_id, M.time_start,M.time_end,


H.hall_id FROM movie B, movie_schedule M, hall H
WHERE B.movie_name = '&v_movie_name' AND B.movie_id = M.movie_id AND H.hall_id
= M.hall_id
ORDER BY movie_id, schedule_id;

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
TTITLE OFF

31
Sample output

32
6.2.3 Query 3: Display the movie description

Purpose: The purpose of this query is to let the user know the description of the movie. The user
can enter a movie description to know what the movie name is and the start time of each hall.

SQL Statement
SET linesize 120
SET pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

ACCEPT v_movie_desc char format 'A10' PROMPT 'Enter Movie Description :'

COLUMN movie_id FORMAT A10 HEADING "Movie ID";


COLUMN movie_name FORMAT A30 HEADING "Movie Name";
COLUMN movie_language FORMAT A15 HEADING "Language";
COLUMN movie_desc FORMAT A13 HEADING "Description";
COLUMN hall_id FORMAT A05 HEADING "Hall ID";

TTITLE CENTER 'Movie Name for category '&v_movie_desc-


RIGHT 'Page:' FORMAT 999 SQL.PNO SKIP 2
BREAK ON movie_name SKIP 1 ON movie_id ON movie_desc ON movie_language

SELECT M.movie_id, M.movie_name, M.movie_language, M.movie_desc, H.hall_id FROM movie


M, movie_schedule N, hall H
WHERE M.movie_id = N.movie_id AND H.hall_id = N.hall_id AND M.movie_desc =
'&v_movie_desc'
ORDER BY movie_id;

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
TTITLE OFF

33
Sample Output

34
6.2.4 Query 4: Display payment method that use for customer

Purpose: The purpose of this query is to allow users to check the payment method that use for
customer from 21 January 2021 to 22 April 2021. In this query, users can easily know the customer's
payment method that have use from 21 January 2021 to 22 Jun 2022.

SQL Statement

SET linesize 120


SET pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

--3-OCT-2022 - 1-JAN-2023

ACCEPT v_startDate CHAR FORMAT 'A11' PROMPT 'Enter the start date(DD-MON-
YYYY):'
ACCEPT v_endDate CHAR FORMAT 'A11' PROMPT 'Enter the end date(DD-MON-YYYY):'

COLUMN no FORMAT 99 HEADING "No.";


COLUMN payment_id FORMAT A10 HEADING "Payment ID";
COLUMN payment_date FORMAT A11 HEADING "Date";
COLUMN cust_id FORMAT A20 HEADING "Customer ID";
COLUMN cust_name FORMAT A30 HEADING "Customer";
COLUMN payment_method FORMAT A15 HEADING "Payment Method";
COLUMN amount FORMAT $9999.99 HEADING "Payment Amount (RM)";

TTITLE CENTER 'Payments Received From ' v_startDate ' To ' v_endDate-
RIGHT'Page:'FORMAT 999 SQL.PNO SKIP 1
BREAK ON payment_id SKIP 1 ON booking_date

SELECT
ROW_NUMBER() OVER(
ORDER BY B.payment_id
) no,
B.payment_id,
P.payment_date,
B.cust_id,
C.cust_name,
P.amount,
P.payment_method
FROM
payment P,
customer C,
booking B
WHERE
B.payment_id = P.payment_id AND
C.cust_id = B.cust_id AND
P.payment_date BETWEEN '&v_startDate' AND '&v_endDate';

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
TTITLE OFF

35
Sample output

6.2.5 Query 5: Total price for each category

36
Purpose: The purpose of this query is to allow users to search the item description of each item.
Users will easily get the name of the Item and can show how much the customer spent.

SQL Statement

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';


SET LINESIZE 120
SET PAGESIZE 100

COLUMN category FORMAT A10 HEADING "Category";


COLUMN quantity FORMAT 99 HEADING "Qty";
COLUMN subtotal FORMAT $999999.99 HEADING "Subtotal (RM)";
COLUMN no FORMAT 99 HEADING "NO.";

TTITLE CENTER ' Total Sales Of Category Orders '-


RIGHT'PAGE:'FORMAT 999 SQL.PNO SKIP 2
BREAK ON category SKIP 2 ON Subtotal

SELECT ROW_NUMBER() OVER(


ORDER BY I.category
)no,
I.category , SUM(O.quantity * item_price) AS subtotal
FROM order_detail O, item I
WHERE O.item_id = I.item_id
GROUP BY I.category;

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
TTITLE OFF

Sample output

37
6.3 Gan Eng Kiat

38
6.3.1 Query 1: Display how many couple seats have been booked.
Purpose: To get the quantity of customer ordered the couple seat for future purpose to
decrease or increase the couple seat.

SQL Statement
Set linesize 120
Set pagesize 100
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

COLUMN seat_category FORMAT A15 HEADING "Seat Category";


COLUMN seat_id FORMAT A10 HEADING "Seat ID";

TTITLE LEFT 'Number of customers that booked couple seats' SKIP 2

SELECT COUNT(S.seat_category), S.seat_category, S.seat_id


FROM seat S, booking_detail B
WHERE S.seat_category='Couple' and S.seat_id= B.seat_id
GROUP BY S.seat_category, S.seat_id;

CLEAR COLUMNS
TTITLE OFF

Sample Output

39
6.3.2 Query 2: The quantity of item customer ordered

40
Purpose: To know which food and toy are attracting the customer most so that they can
improve or innovate some interesting toy and attractive food.

SQL Statement
Set linesize 120
Set pagesize 150

COLUMN item_id FORMAT A10 HEADING 'Total Item';


COLUMN item_desc FORMAT A20 HEADING 'Item Description';

TTITLE LEFT 'Number of item sold' SKIP 2

SELECT COUNT(i.item_id), i.item_id, i.item_desc, o.quantity


FROM item i, order_detail o
WHERE i.item_id = o.item_id
GROUP BY i.item_desc, i.item_id, o.quantity;

CLEAR COLUMNS
TTITLE OFF

Sample Output

41
42
43
6.3.3 Query 3: Quantity of customer booking on a certain date.

Purpose: To let the user know how many bookings have been made on a certain date.

SQL Statement
Set linesize 120
Set pagesize 150

ACCEPT v_startDate CHAR FORMAT 'A11' PROMPT ' Enter the start date: '
ACCEPT v_endDate CHAR FORMAT 'A11' PROMPT ' Enter the end date: '

COLUMN booking_id FORMAT A10 HEADING'Booking ID';

TTITLE LEFT 'Number of booking within the certain date' SKIP 2

SELECT COUNT(booking_id) AS Quantity, booking_id, booking_date


FROM booking
WHERE booking_date between '&v_startDate' AND '&v_endDate'
GROUP BY booking_id, booking_date;

CLEAR COLUMNS
TTITLE OFF

44
Sample Output

45
6.3.4 Query 4: Display which movie have show at the hall.

Purpose: To let users what the hall show what movie and show how many movie

SQL Statement
Set linesize 120
Set pagesize 250

prompt 'list of movie and hall'

COLUMN movie_name FORMAT A30 HEADING 'Movie Name';


COLUMN movie_id FORMAT A10 HEADING 'Movie ID';
COLUMN hall_id FORMAT A10 HEADING 'HALL';

SELECT movie_name, m.movie_id, h.hall_id


FROM movie_schedule s, hall h, movie m
WHERE s.movie_id=m.movie_id
ORDER BY h.hall_id;

TTITLE OFF
CLEAR COLUMNS

46
Sample Output

47
48
6.3.5 Query 5: Payment method the customer used.

Purpose: To let users know they need to form many payment methods for users to
increase the booking. More ways to pay is more user friendly.

SQL Statement
Set linesize 120
Set pagesize 160

TTITLE LEFT 'Payment Method used by customer' SKIP 2

COLUMN cust_id FORMAT A15 HEADING 'Customer ID';


COLUMN cust_name FORMAT A25 HEADING 'Customer Name';
COLUMN payment_method FORMAT A20 HEADING 'Payment Method';

SELECT cust_id,cust_name, payment_method, count(payment_method) AS Frequency


FROM payment, customer
GROUP BY payment_method, cust_id, cust_name;

CLEAR COLUMNS
TTITLE OFF

49
Sample Output

50
51
Reference

1. Copyright 1999-2021 by Refsnes Data, W3school, create table, viewed 10/03/2021


<https://www.w3schools.com/sql/sql_create_table.asp>
2. Draw.io, computer software, downloaded 10/02/2021 <https://draw-io.en.softonic.com>

52

You might also like