Вы находитесь на странице: 1из 16

MULTIPLEX

DATABASE
Created by :
Aashish Ramakrishnan
Aravind Sharma
K R Anand
Shantha Raju N

1.INTRODUCTION
We have created a working database of a movie theatre.
The various functionalities of the database are:
i. It keeps track of the movie information running in various halls.
ii. It manages customer information efficiently.
iii. Provides for booking in movie theatre according to various classes.
iv. Hall management is incorporated.


PROGRAMMING
THE DATABASE
SCHEMA DIAGRAM
Movie
Hall
Seat_block
Customer
Booking
CREATION OF TABLES
TABLE Movie
CREATE TABLE Movie
(
movie_id NUMBER(3),
movie_name VARCHAR(25),
language VARCHAR(10),
runtime VARCHAR(8),
CONSTRAINT primary_key_movie
PRIMARY KEY(movie_id)
);
Table Hall
CREATE TABLE Hall
(
hall_id NUMBER(3),
hall_location VARCHAR(12),
movie_id NUMBER(3),
CONSTRAINT primary_key_hall
PRIMARY KEY(hall_id),
CONSTRAINT foreign_key_hall
FOREIGN KEY(movie_id) REFERENCES
Movie(movie_id)
);
Table Seat_block
CREATE TABLE Seat_block
(
class_id NUMBER(3),
price FLOAT,
description VARCHAR(10),
CONSTRAINT primary_key_block
PRIMARY KEY(class_id)
);
Table Customer
CREATE TABLE Customer
(
customer_id NUMBER(3),
customer_name VARCHAR(30),
balance FLOAT,
CONSTRAINT priomary_key_customer
PRIMARY KEY(customer_id)
);
Table Booking
CREATE TABLE booking
(
customer_id NUMBER(3),
movie_id NUMBER(3),
class_id NUMBER(3),
hall_id NUMBER(3),
date_of_booking DATE,
CONSTRAINT foreign_key_cust_id
FOREIGN KEY(customer_id) REFERENCES Customer(customer_id),
CONSTRAINT foreign_key_movie_id
FOREIGN KEY(movie_id) REFERENCES Movie(movie_id),
CONSTRAINT foreign_key_hall_id
FOREIGN KEY(hall_id) REFERENCES Hall(hall_id)
)
SQL>SELECT * FROM Movie;
MOVIE_ID MOVIE_NAME LANGUAGE RUNTIME
------------ ------------------------------- -------------- ----------
101 3 IDIOTS HINDI 02:30
102 SHAWSHANK REDEMPTION ENGLISH 02:15
103 INCEPTION ENGLISH 02:00
104 ONG BAK THAI 02:10
105 UGRAMM KANNADA 02:30
106 ROCKET SINGH HINDI 02:45
SQL>SELECT * FROM Customer;
CUSTOMER_ID CUSTOMER_NAME BALANCE
----------------- -------------------------------- ----------
401 K R ANAND 500
402 ARAVIND SHARMA 1550
403 AASHISH RADHAKRISHNAN 1900
404 SHANTHA RAJU N 1000
405 VIJAY KUMAR P 10000
SQL> SELECT * FROM Hall;

HALL_ID HALL_LOCATION MOVIE_ID
---------- -------------------- ------------
201 1ST FLOOR 105
202 2ND FLOOR 102
203 5TH FLOOR 103
204 2ND FLOOR 104
205 1ST FLOOR 101
206 6TH FLOOR 105
207 2ND FLOOR 106
208 5TH FLOOR 106
209 3RD FLOOR 106

SQL>SELECT * FROM Seat_block;

CLASS_ID PRICE DESCRIPTION
---------- ---------- ----------------
301 350 GOLD
302 200 SILVER
303 150 BRONZE
SQL>SELECT * FROM Booking;

CUSTOMER_ID MOVIE_ID HALL_ID CLASS_ID DATE_OF_BOOKING
----------------- ----------- ---------- ----------- -----------------------
402 101 205 303 29-JAN-14
403 101 205 303 30-JAN-14
405 102 202 302 04-JUL-14
404 103 203 302 15-AUG-14
402 104 204 303 29-JAN-14
403 105 201 301 10-DEC-14
403 103 203 301 25-MAR-14
402 103 206 301 20-SEP-14
QUERIES
1. Select all the customers who have booked two movies at the same date
SELECT DISTINCT(C.customer_name)
FROM Customer C
WHERE C.customer_id IN
( CUSTOMER_NAME
SELECT b1.customer_id ---------------------
FROM Booking b1,Booking b2 ARAVIND SHARMA
WHERE
b1.customer_id=b2.customer_id AND
b1.movie_id<>b2.movie_id AND
b1.date_of_booking=b2.date_of_booking
);



2. CALCULATE THE REVENUE OF EACH HALL
SELECT B.hall_id,SUM(S.price)
FROM Booking B,Seat_block S
WHERE
B.class_id=S.class_id
GROUP BY B.hall_id;
HALL_ID SUM(S.PRICE)
---------- ----------------
201 350
202 200
203 550
204 150
205 300
206 350
3. LIST ALL CUSTOMERS WHO HAVE BOOKED IN 2
ND
FLOOR
SELECT DISTINCT(C.customer_name)
FROM Customer C,Booking B,Hall H
WHERE
C.customer_id=B.customer_id AND
B.movie_id=H.movie_id AND
H.hall_location='2ND FLOOR';
CUSTOMER_NAME
---------------------
ARAVIND SHARMA
VIJAY KUMAR P
4.Find all movies that are running in two or more halls
SELECT M.movie_name
FROM Movie M
WHERE M.movie_id IN
(
SELECT H.movie_id
FROM Hall H
GROUP BY H.movie_id
HAVING COUNT(*)>=2
);
MOVIE_NAME
-------------------------
UGRAMM
ROCKET SINGH
5. Select language whose movie has 2 or more than 2 booking for class 301
SELECT DISTINCT(M1.language)
FROM Movie M1 WHERE EXISTS
(
SELECT B.class_id
FROM Booking B,Movie M2
WHERE
M1.language=M2.language AND
B.movie_id=M2.movie_id AND
B.class_id=301
GROUP BY class_id
HAVING COUNT(*)>1
);
SELECT DISTINCT(M1.language)
FROM Movie M1 WHERE
(
SELECT COUNT(*)
FROM Booking B,Movie M2
WHERE
M1.language=M2.language AND
B.movie_id=M2.movie_id AND
B.class_id=301
)>1;
LANGUAGE
-------------
ENGLISH
THANK YOU