Visit:: Join Telegram To Get Instant Updates: Contact: MAIL: Instagram: Instagram
Visit:: Join Telegram To Get Instant Updates: Contact: MAIL: Instagram: Instagram
io
INSTAGRAM: www.instagram.com/hemanthraj_hemu/
INSTAGRAM: www.instagram.com/futurevisionbie/
1|Page https://hemanthrajhemu.github.io
----------------------------------------------------------------------------------------------
Consider the schema for Movie Database:
https://hemanthrajhemu.github.io
2|Page https://hemanthrajhemu.github.io
----------------------------------------------------------------------------------------------
SCHEMA DIAGRAM:
--------------------------------------------------------------------------------------------------------------------------
https://hemanthrajhemu.github.io
3|Page https://hemanthrajhemu.github.io
-------------------------------------------------------------------------------------------------------
(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.
NOW RUN.
NOW RUN.
https://hemanthrajhemu.github.io
5|Page https://hemanthrajhemu.github.io
NOW RUN.
-------------------------------------------------------------------------------------------------------
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');
https://hemanthrajhemu.github.io
10 | P a g e https://hemanthrajhemu.github.io
https://hemanthrajhemu.github.io
11 | P a g e https://hemanthrajhemu.github.io
-------------------------------------------------------------------------------------------------------
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
----------------------------------------------------------------------------------------
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
-------------------------------------------------------------------------------------------------------
THE END
-------------------------------------------------------------------------------------------------------
https://hemanthrajhemu.github.io