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

Visit:: Join Telegram To Get Instant Updates: Contact: MAIL: Instagram: Instagram

The document provides information about a database schema for a movie database including tables for actors, directors, movies, movie cast, and ratings. It includes SQL queries to retrieve information from the tables like movies directed by Hitchcock and actors in movies between 2000 and 2015. It also shows how to create the tables, insert sample data, and retrieve the inserted data.

Uploaded by

study material
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)
98 views

Visit:: Join Telegram To Get Instant Updates: Contact: MAIL: Instagram: Instagram

The document provides information about a database schema for a movie database including tables for actors, directors, movies, movie cast, and ratings. It includes SQL queries to retrieve information from the tables like movies directed by Hitchcock and actors in movies between 2000 and 2015. It also shows how to create the tables, insert sample data, and retrieve the inserted data.

Uploaded by

study material
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/ 19

Visit : https://hemanthrajhemu.github.

io

Join Telegram to get Instant Updates: https://bit.ly/2GKiHnJ

Contact: MAIL: futurevisionbie@gmail.com

INSTAGRAM: www.instagram.com/hemanthraj_hemu/

INSTAGRAM: www.instagram.com/futurevisionbie/
1|Page https://hemanthrajhemu.github.io

[As per Choice Based Credit System (CBCS) scheme]


(Effective from the academic year 2017-2018)
SEMESTER – V
Subject Code:17CSL58 IA Marks: 40
Exam Marks: 60 Exam Hours: 03
----------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------
Consider the schema for Movie Database:

ACTOR(Act_id, Act_Name, Act_Gender)


DIRECTOR(Dir_id, Dir_Name, Dir_Phone)
MOVIES(Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)
MOVIE_CAST(Act_id, Mov_id, Role)
RATING(Mov_id, Rev_Stars)
Write SQL queries to
1. List the titles of all movies directed by ‘Hitchcock’.
2. Find the movie names where one or more actors acted in two or more
movies.
3. List all actors who acted in a movie before 2000 and also in a movie
after 2015
(use JOIN operation).
4. Find the title of movies and number of stars for each movie that has at
least one
rating and find the highest number of stars that movie received. Sort the
result
by movie title.
5. Update rating of all movies directed by ‘Steven Spielberg’ to 5.

https://hemanthrajhemu.github.io
2|Page https://hemanthrajhemu.github.io

----------------------------------------------------------------------------------------------
SCHEMA DIAGRAM:
--------------------------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
3|Page https://hemanthrajhemu.github.io

-------------------------------------------------------------------------------------------------------

STEPS TO OPEN THE ORACLE DATABASE – 10G


EXPRESS EDITION
-------------------------------------------------------------------------------------------------------
Step 1: Open the Browser (Preferred Chrome).
Step 2: http://127.0.0.1:8080/ Enter the link on the browser.
Step 3: login with your id and password (finding difficulty in login in go to the
link to know in-depth details
https://hemanthrajhemu.github.io/FutureVisionBIE/WP/5CSE/DBMS_LAB_INFO.html

(Note Username is the system by default & Password is the passkey you entered
in the installation)

Step 4: Now click on SQL->SQL Commands. This is the place where we execute
the SQL Commands.

Step 5: you are in SQL Command Now you can Create table, create view, Run
Queries here & lot more.

https://hemanthrajhemu.github.io
4|Page https://hemanthrajhemu.github.io

-------------------------------------------------------------------------------------------------------
Create Table: (Follow the Schema Diagram in Creating the Data Base)
-------------------------------------------------------------------------------------------------------
1. Create Table for ACTOR
CREATE TABLE ACTOR(
ACT_ID INTEGER PRIMARY KEY,
ACT_NAME VARCHAR(30) NOT NULL,
ACT_GENDER VARCHAR(10) NOT NULL);

NOW RUN.

2. Create Table for DIRECTOR


CREATE TABLE DIRECTOR(
DIR_ID INTEGER PRIMARY KEY,
DIR_NAME VARCHAR(30) NOT NULL,
DIR_PHONE INTEGER);

NOW RUN.

3. Create Table for MOVIES

CREATE TABLE MOVIES(


MOV_ID INTEGER PRIMARY KEY,
MOV_TITLE VARCHAR(30) NOT NULL,
MOV_YEAR INTEGER NOT NULL,
MOV_LANG VARCHAR(10),
DIR_ID INTEGER REFERENCES
DIRECTOR(DIR_ID)
ON DELETE CASCADE);

NOW RUN.

https://hemanthrajhemu.github.io
5|Page https://hemanthrajhemu.github.io

4. Create Table for MOVIE_CASTE

CREATE TABLE MOVIE_CASTE(


ACT_ID INTEGER REFERENCES
ACTOR(ACT_ID)
ON DELETE CASCADE,
MOV_ID INTEGER REFERENCES
MOVIES(MOV_ID)
ON DELETE CASCADE,
ROLE VARCHAR(30) NOT NULL);

NOW RUN.

5. Create Table for RATING

CREATE TABLE RATING(


MOV_ID INTEGER REFERENCES MOVIES(MOV_ID) ON DELETE CASCADE,
REV_STARS INTEGER NOT NULL);

-------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
6|Page https://hemanthrajhemu.github.io

-------------------------------------------------------------------------------------------------------
TABLE DESCRIPTION
-------------------------------------------------------------------------------------------------------
1. DESC ACTOR;

------------------------------------------------------------------------------------------------------------

2. DESC DIRECTOR;

-------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
7|Page https://hemanthrajhemu.github.io

3. DESC MOVIES;

-------------------------------------------------------------------------------------------------------

4. DESC MOVIE_CASTE;

-------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
8|Page https://hemanthrajhemu.github.io

5. DESC RATING;

-------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
9|Page https://hemanthrajhemu.github.io

-------------------------------------------------------------------------------------------------------
INSERTION OF VALUES TO TABLE
-------------------------------------------------------------------------------------------------------
1. VALUES INTO ACTOR
INSERT INTO ACTOR VALUES(<ACT_ID> , <ACT_NAME>, <ACT_GENDER> );
INSERT INTO ACTOR VALUES(1001,'PRABHAS','MALE');
INSERT INTO ACTOR VALUES(1002,'RAJKUMAR','MALE');
INSERT INTO ACTOR VALUES(1003,'SNEHA','FEMALE');
INSERT INTO ACTOR VALUES(1004,'AISHWARAYA','FEMALE');
INSERT INTO ACTOR VALUES(1005,'RITHIK','MALE');

2. VALUES INTO DIRECTOR

INSERT INTO DIRECTOR VALUES(<DIR_ID>,<DIR_NAME>,<DIR_PHONE>);


INSERT INTO DIRECTOR VALUES(2001,'HITCHCOCK','9639639630');
INSERT INTO DIRECTOR VALUES(2002,'STEVEN SPIELBERG','8887779991');
INSERT INTO DIRECTOR VALUES(2003,'RAJMOULI','9995556662');
INSERT INTO DIRECTOR VALUES(2004,'ATLEE','9874569874');
INSERT INTO DIRECTOR VALUES(2005,'HEMANTH','9874555780');

https://hemanthrajhemu.github.io
10 | P a g e https://hemanthrajhemu.github.io

3. VALUES INTO MOVIES

INSERT INTO MOVIES


VALUES(<MOV_ID>,<MOV_TITLE>,<MOV_YEAR>,<MOV_LANG>,<DIR_ID>);
INSERT INTO MOVIES VALUES(3001,'BAHUBALI',2014,'HINDI',2003);
INSERT INTO MOVIES VALUES(3002,'BAHUBALI',2014,'TELUGU',2003);
INSERT INTO MOVIES VALUES(3003,'BAHUBALI 2',2016,'HINDI',2003);
INSERT INTO MOVIES VALUES(3004,'BAHUBALI 2',2016,'TELUGU',2003);
INSERT INTO MOVIES VALUES(3005,'BABY DRIVER ',1999,'ENGLISH',2001);
INSERT INTO MOVIES VALUES(3006,'TERMINATOR',2000,'ENGLISH',2002);

4. VALUES INTO MOVIE_CASTE

INSERT INTO MOVIE_CASTE VALUES(<ACT_ID>,<MOV_ID>,<ROLE>);

INSERT INTO MOVIE_CASTE VALUES(1001,3001,'HERO');


INSERT INTO MOVIE_CASTE VALUES(1001,3002,'HERO');
INSERT INTO MOVIE_CASTE VALUES(1001,3003,'HERO');
INSERT INTO MOVIE_CASTE VALUES(1001,3004,'HERO');
INSERT INTO MOVIE_CASTE VALUES(1003,3001,'HEROINE');
INSERT INTO MOVIE_CASTE VALUES(1003,3002,'HEROINE');
INSERT INTO MOVIE_CASTE VALUES(1004,3001,'HEROINE');
INSERT INTO MOVIE_CASTE VALUES(1004,3002,'HEROINE');
INSERT INTO MOVIE_CASTE VALUES(1001,3005,'HERO');
INSERT INTO MOVIE_CASTE VALUES(1001,3006,'HERO');

https://hemanthrajhemu.github.io
11 | P a g e https://hemanthrajhemu.github.io

5. VALUES INTO RATING

INSERT INTO RATING VALUES(<MOV_ID>,<REV_STARS>);


INSERT INTO RATING VALUES(3001,'8');
INSERT INTO RATING VALUES(3002,'7');
INSERT INTO RATING VALUES(3003,'6');
INSERT INTO RATING VALUES(3004,'7');
INSERT INTO RATING VALUES(3005,'4');
INSERT INTO RATING VALUES(3006,'2');

-------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
12 | P a g e https://hemanthrajhemu.github.io

-------------------------------------------------------------------------------------------------------
RETRIEVAL OF INSERTED VALUES
-------------------------------------------------------------------------------------------------------
1. ACTORS:
SELECT * FROM ACTOR;

2. DIRECTOR:
SELECT * FROM DIRECTOR;

https://hemanthrajhemu.github.io
13 | P a g e https://hemanthrajhemu.github.io

3. MOVIES:
SELECT * FROM MOVIES;

4. MOVIE_CASTE:
SELECT * FROM MOVIE_CASTE;

https://hemanthrajhemu.github.io
14 | P a g e https://hemanthrajhemu.github.io

5. RATING:
SELECT * FROM RATING;

-------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
15 | P a g e https://hemanthrajhemu.github.io

-------------------------------------------------------------------------------------------------------
QUERIES
-------------------------------------------------------------------------------------------------------
1. List the titles of all movies directed by ‘Hitchcock’.
SELECT M.MOV_TITLE FROM MOVIES M,DIRECTOR D WHERE
D.DIR_NAME='HITCHCOCK' AND D.DIR_ID=M.DIR_ID;

2. Find the movie names where one or more actors acted in two or more
movies.
SELECT MOV_TITLE FROM MOVIES M,MOVIE_CASTE MC
WHERE M.MOV_ID=MC.MOV_ID AND ACT_ID IN
(SELECT ACT_ID FROM MOVIE_CASTE
GROUP BY ACT_ID HAVING COUNT(ACT_ID)>1)
GROUP BY MOV_TITLE HAVING COUNT(MOV_TITLE)>1;

https://hemanthrajhemu.github.io
16 | P a g e https://hemanthrajhemu.github.io

3. List all actors who acted in a movie before 2000 and also in a movie
after 2015.
SELECT ACT_NAME FROM ACTOR A, MOVIE_CASTE MC WHERE
A.ACT_ID=MC.ACT_ID AND MC.MOV_ID IN (SELECT MOV_ID FROM MOVIES
WHERE MOV_YEAR NOT BETWEEN 2000 AND 2015) GROUP BY ACT_NAME
HAVING COUNT(*)>1;

4. Find the title of movies and number of stars for each movie that has
at least one rating and find the highest number of stars that movie
received. Sort the result by movie title.
SELECT MOV_TITLE,MAX(REV_STARS) FROM MOVIES M INNER JOIN RATING
R ON M.MOV_ID=R.MOV_ID GROUP BY MOV_TITLE ORDER BY MOV_TITLE;

https://hemanthrajhemu.github.io
17 | P a g e https://hemanthrajhemu.github.io

5. Update rating of all movies directed by ‘Steven Spielberg’ to 5.


SELECT * FROM RATING;

----------------------------------------------------------------------------------------
UPDATE RATING SET REV_STARS=5 WHERE MOV_ID IN (SELECT MOV_ID
FROM MOVIES M,DIRECTOR D WHERE D.DIR_ID=M.DIR_ID AND
DIR_NAME='STEVEN SPIELBERG');

----------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io
18 | P a g e https://hemanthrajhemu.github.io

SELECT * FROM RATING;

-------------------------------------------------------------------------------------------------------
THE END
-------------------------------------------------------------------------------------------------------

https://hemanthrajhemu.github.io

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy