DBSM Assignment
DBSM Assignment
Assignment
Team member:
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.
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)
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:
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.
Assumption:
1. Customers are able to check their booking status from their individual account.
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
4
Task 4: Create database table in Oracle
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'))
);
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'))
);
7
Task 5: Create records
8
INSERT INTO payment VALUES ('PM0001', 65.20, 'CREDIT CARD', '1-Jan-2021');
9
INSERT INTO booking_detail VALUES ('BK0001', 'MS0006', 'H06R03S01', 14.00);
10
INSERT INTO booking_detail VALUES ('BK0011', 'MS0010', 'H10R02S07', 14.00);
11
INSERT INTO booking_detail VALUES ('BK0022', 'MS0011', 'H11R03S02', 14.00);
12
INSERT INTO booking_detail VALUES ('BK0033', 'MS0007', 'H07R03S08', 14.00);
13
5.7 Movie schedule record
INSERT INTO movie_schedule VALUES ('MS0001','01:00 PM','03:30 PM','M0001','H001');
14
5.9 Order detail record
INSERT INTO order_detail VALUES ('BK0001', 'IF001', 'PM0001', 2, 11.60);
15
INSERT INTO order_detail VALUES ('BK0032', 'IF024', 'PM0032', 1, 12.23);
16
INSERT INTO order_detail VALUES ('BK0064', 'IB020', 'PM0064', 4, 7.72);
17
INSERT INTO order_detail VALUES ('BK0096', 'IT017', 'PM0096', 1, 11.75);
18
Task 6: Create Queries
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;
CLEAR SCREEN
PROMPT 'Get customer who have make booking at age 18 and 28'
PROMPT
PROMPT
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 :'
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;
CLEAR SCREEN
PROMPT 'Get customer who have get the special festival discount'
PROMPT
PROMPT
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';
TTITLE CENTER 'Total amount detail for ' v_Start_Date ' to ' v_End_Date-
RIGHT 'Page No: ' FORMAT 999 SQL.PNO SKIP 2
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';
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
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';
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
ACCEPT v_movie_name char format 'A30' PROMPT 'Enter Movie Name :'
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 :'
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
--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):'
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
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
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';
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
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: '
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
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
CLEAR COLUMNS
TTITLE OFF
49
Sample Output
50
51
Reference
52