0% found this document useful (0 votes)
30 views16 pages

Chill

....

Uploaded by

Mg Htet Wai Yan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views16 pages

Chill

....

Uploaded by

Mg Htet Wai Yan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

1.

Description of “Movie for Chill” Project

Our database project is designed to bring the joy of cinematic entertainment right to the
homes of our users. With this platform, users will have the convenience of watching movies and
series from the comfort of their homes. Our primary focus is on ensuring user satisfaction and
data security. Specially, we provide separate interface for different type such as movie and series.
For loyal and high -spending customers ,there is a system to pay cashback for the vip customers.

1
2. Objectives

 To easily access and enjoy a wide range of movies and series from their homes.
 To keep your data and payment details in safe.
 To make sure that unauthorized access can’t be grant.
 To reduce energy effort for traveling to cinema.
 To rewatch every movie or series whenever users want.

2
4. Data Dictionary

Table Attribute Type Required PK/FK FK reference


table

all_item itemID varchar(5) YES PK


item_name varchar(40) YES
category varchar(30)
type varchar(15)
price int YES
viewed int
box_office int
user_login userID varchar(5) YES PK
user_name varchar(30) YES
password varchar(10)
gmail varchar(30)
wallet int
download_list userID varchar(5) YES PK/FK user_login
itemID varchar(5) YES PK/FK all_item
qty int
date date
movie_collection No int PK
movieID varchar(5)
movie_name varchar(40)
category varchar(30)
price int
series_collection No int PK
seriesID varchar(5)
series_name varchar(40)
category varchar(30)
price int
Vip_customer No int PK
customer_name varchar(30)
cashback int

3
5. Building tables with SQL language

(i) CREATE TABLE all_item(itemid VARCHAR(5)PRIMARY KEY,item_name


VARCHAR(40) NOT NULL,category VARCHAR(30)NOT NULL,type VARCHAR(15) NOT

itemID item_name category type price viewed box_office


i1 Spider_man Animation Movie 20 0 0
i2 Blue beetle Action Movie 15 0 0
i3 Dr strange Fantasy Movie 15 0 0
i4 Star war Fantasy Movie 15 0 0
i5 Dexter Thriller Series 15 0 0
i6 Moving Action Series 15 0 0
I7 Masked girl Comedy Series 15 0 0
I8 Xo, kitty Romance Series 15 0 0
NULL,price INT,viewed INT,box_office INT);

Table 1 : all_item

(ii) CREATE TABLE user_login(userid VARCHAR(5) PRIMARY KEY,user_name


VARCHAR(30) NOT NULL,password VARCHAR(10)NOT NULL,gmail
VARCHAR(30),wallet INT NOT NULL);

4
userID user_name password gmail wallet
u1 Pyae Sone Toe passtoe [email protected] 3000
u2 Todoroki jujustsu [email protected] 5000
u3 Andrew Tate brotate [email protected] 7000
u4 Kyaw Gyi kyaw1554 [email protected] 6500
u5 Sophia sophie4u [email protected] 4000
u6 Nwe ni ni nwenitoe55 [email protected] 5500

Table 2 : user_login

(iii) CREATE TABLE download_list (userID VARCHAR(5), itemID VARCHAR(5), qty INT,
date DATE,PRIMARY KEY(userid,itemid), FOREIGN KEY(userID) REFERENCES
user_login(userID) ON DELETE CASCADE ON UPDATE CASCADE , FOREIGN
KEY(itemID) REFERENCES all_item(itemID) ON DELETE CASCADE ON UPDATE
CASCADE );

userID itemID qty date


u1 i1 1 2023-8-27
u2 i2 1 2023-8-27
u1 i2 1 2023-8-28
u3 i1 1 2023-8-28
u5 i4 2 2023-8-29

Table 3 : download_list

(iv) CREATE TABLE movie_collection(No INT PRIMARY KEY AUTO_INCREMENT ,


movieID VARCHAR(5)NOT NULL, movie_name VARCHAR(40) NOT NULL, category
VARCHAR(30) NOT NULL, price INT);

5
Table 4 : movie_collection

(v) CREATE TABLE series_collection(No INT PRIMARY KEY AUTO_INCREMENT ,


seriesID VARCHAR(5)NOT NULL, series_name VARCHAR(40) NOT NULL, category
VARCHAR(30) NOT NULL, price INT);

no seriesID series_name category price


1 i5 Dexter Thriller 20
2 i6 moving Action 20
3 i7 Masked girl Comedy 10
4 i8 XO, Kitty Romance 10

No customerID customer_name gmail cashback


1 u2 Todoroki [email protected] 500

No movieID Movie_name Category Price


1 i1 spider_man animation 20
2 i2 blue beetle action 15
3 i3 Dr strange Fantasy 10
4 i4 Star war Fantasy 10
Table 5 : series_collection

(vi) CREATE TABLE vip_customer(No INT PRIMARY KEY AUTO_INCREMENT,


customerID VARCHAR(5)NOT NULL,customer_name VARCHAR(30)NOT NULL,gmail
VARCHAR(30),cashback INT);

6
2 u3 Andrew Tate [email protected] 500
3 u4 Kyaw Gyi [email protected] 500

Table 6 : vip_customer

5. Creating username with Password

CREATE USER ‘Andrew’ IDENTIFIED BY ‘andrew123’ ;


CREATE USER ‘Todoroki’ IDENTIFIED BY ‘totosakana4533’ ;
CREATE USER ‘Kyaw Gyi’ IDENTIFIED BY ‘kyawgyi1997’ ;

7
6. View and Privileges of the project

(i) User ‘Andrew’ RETRIEVE privileges over the all_item of itemID, item_name, category, type,
price, viewed, box_office attributes over tuple for category ‘action’.(only)

CREATE VIEW acti AS


SELECT all_item.*
FROM all_item
WHERE all_item.category=’action’;
GRANT SELECT
ON acti
TO ‘Andrew’;

8
User ‘Andrew’ can see all data of action movies .

(ii) User ‘Andrew’ all privileges (RETRIEVE, INSERT, UPDATE, DELETE ) over tuple for
movie price 15 dollars.

CREATE VIEW mov AS


SELECT movie_collection.*
FROM movie_collection
WHERE movie_collection.price=15;

GRANT SELECT, INSERT, UPDATE, DELETE


ON mov
TO ‘Andrew’;

9
User ‘Andrew’ can see movies that cost 15 dollars each.

User ‘Andrew’ can update the category from ‘Fantasy’ to ‘Action’.


(iii)User ‘Andrew’ all privileges ( RETRIEVE, UPDATE, INSERT, DELETE ) over tuple
user_login who download for ‘Spider man’ movie.( only )

CREATE VIEW spider AS


SELECT user_login.*
FROM all_item,user_login,download_list
WHERE user_login.userID=download_list.userID
AND download_list.itemID=all_item.itemID
AND all_item.item_name='Spider man';
GRANT All
ON spider
TO ‘Andrew’;

10
User ‘Andrew’ has all privileges on virtual table ‘spider’. Andrew can see user information who
watched spider man movie.

7. Generating Triggers

7.1 Movie and Series classification triggers


In this project, user can see desire movie and series separately. So, extra tables and triggers are
created.

(1) CREATE TABLE movie_collection(No INT PRIMARY KEY AUTO_INCREMENT ,


movieID VARCHAR(5)NOT NULL, movie_name VARCHAR(40) NOT NULL , category
VARCHAR(30) NOT NULL, price INT );

11
(2) CREATE TABLE series_collection(No INT PRIMARY KEY AUTO_INCREMENT ,
seriesID VARCHAR(5)NOT NULL, series_name VARCHAR(40) NOT NULL, category
VARCHAR(30) NOT NULL, price INT );

Following triggers start activate after insert operation is performed on main table. Triggers detect
incoming item type for movie and series and the record of item will automatically add to their
corresponding table separately..

DELIMITER //
CREATE TRIGGER movie_trig AFTER INSERT ON all_item FOR EACH ROW BEGIN
IF (new.type=” movie “) THEN INSERT INTO movie_collection
(movieID, movie_name, category , price)
VALUES ( new.itemID,new.item_name,new.category,new.price ); END IF; END; //

12
DELIMITER //
CREATE TRIGGER series_trig AFTER INSERT ON all_item FOR EACH ROW
BEGIN IF (new.type=” series “) THEN INSERT INTO
series_collection (seriesID, series_name,category , price ) VALUES
(new.itemID,new.item_name,new.category, new.price ); END IF; END; //

7.2 Most viewed and High Box office triggers

We create some triggers .


So ,user can search most viewed films and their incomes.

(1) The ‘view_trig’ trigger will automatically update after insert on ‘download_list’ table. It will
increase count on ‘viewed’ tuple correspond to the downloaded item.

13
CREATE TRIGGER view_trig
AFTER INSERT on download_list FOR EACH ROW
UPDATE all_item JOIN download_list SET viewed=viewed+1 WHERE
all_item.itemID=new.itemID;

(2) The ‘box_trig’ trigger will calculate and update after insert on ‘download_list’ table. It will
increase amount on ‘box_office’ tuple correspond to the downloaded item.

CREATE TRIGGER box_trig


AFTER INSERT ON download_list FOR EACH ROW
UPDATE all_item JOIN download_list SET
box_office = box_office+new.qty*price WHERE all_item.itemID= new.itemID ;

7.3 Cashback Trigger


There is VIP customer table for user who deposit more money on their user account.

CREATE TABLE vip_customer( No INT PRIMARY KEY AUTO_INCREMENT, customerID


VARCHAR(5) NOT NULL, customer_name VARCHAR(30) NOT NULL, gmail
VARCHAR(30), cashback INT );

14
The ‘vip_trig’ trigger start after insert on ‘user_login’ table. The data of users who filled 5000 or
more amount on ‘wallet’ tuple will be added on ‘vip_customer’ and gave them 500
simultaneously.

DELIMITER //

CREATE TRIGGER vip_trig AFTER INSERT ON user_login FOR EACH ROW


BEGIN IF (new.wallet>=5000) THEN
INSERT INTO vip_customer (customerID, customer_name, gmail, cashback)
VALUES (new.userID ,new.user_name ,new.gmail ,500 ); END IF; END; //

8. Conclusion

In conclusion, our movie database project offers a convenient and secure solution for
users to access a vast library of movies, series, and popular films. Our commitment to user
satisfaction is evident through the availability of the most-viewed and highest-earning videos on
our platform, all offered at reasonable prices. We believe that our interface provides an easy and

15
enjoyable experience for all movie enthusiasts, making home entertainment accessible to
everyone.

16

You might also like