0% found this document useful (0 votes)
33 views14 pages

Movie Database

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

Movie Database

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

MOVIE DATABASE

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.
• 1. List the titles of all movies directed by
‘Hitchcock’.
select mov_title
from movies m, director d
where m.dir_id = d.dir_id and
d.dir_name ='Hitchcock';
2. Find the movie names where one or more
actors acted in two or more movies.
select distinct mov_title
from movies m, movie_cast mc
where m.mov_id = mc.mov_id and
(select count(mov_id)
from movie_cast
where act_id =mc.act_id)>=2;
3. List all actors who acted in a movie before 2000 and also
in a movie after 2015 (use JOIN operation).

select act_name
from actor a join movie_cast mc on a.act_id = mc.act_id
join movies m on mc.mov_id = m.mov_id
where m.mov_year<2000

Intersect

select act_name
from actor a join movie_cast mc on a.act_id = mc.act_id
join movies m on mc.mov_id = m.mov_id
where m.mov_year>2015;
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, rating r
where m.mov_id = r.mov_id
group by (m.mov_title,m.mov_id)
order by m.mov_title;
5. Update rating of all movies directed by ‘Steven
Spielberg’ to 5

update rating set rev_stars=5


where mov_id in
(select m.mov_id
from movies m,director d
where m.dir_id = d.dir_id and d.dir_name=' Steven
Spielberg ');

You might also like