Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
table: movie_cast
act_id | mov_id | role
--------+--------+--------------------------------
101 | 901 | John Scottie Ferguson
102 | 902 | Miss Giddens
103 | 903 | T.E. Lawrence
104 | 904 | Michael
105 | 905 | Antonio Salieri
106 | 906 | Rick Deckard
table: movie
table: director
dir_id | mov_id
--------+--------
201 | 901
202 | 902
203 | 903
204 | 904
205 | 905
206 | 906
207 | 907
208 | 908
rev_id | rev_name
--------+--------------------------------
9001 | Righty Sock
9002 | Jack Malvern
9003 | Flagrant Baronessa
9004 | Alec Shaw
9005 |
9006 | Victor Woeltjen
9007 | Simon Wright
9008 | Neal Wruck
9009 | Paul Monks
9010 | Mike Salvati
Tasks:
1 .Write a query in SQL to list all the information of the actors who played a role in
the movie 'Annie Hall'.
Ans:
SELECT *
FROM actor
SELECT act_id
FROM movie_cast
WHERE mov_id IN (
SELECT mov_id
FROM movie
));
2. Write a query in SQL to find the name of the director (first and last names) who
directed a movie that casted a role for 'Eyes Wide Shut'.
FROM director
WHERE dir_id in (
SELECT dir_id
FROM movie_direction
SELECT mov_id
SELECT role
FROM movie_cast
WHERE mov_id IN (
SELECT mov_id
FROM movie
3. Write a query in SQL to list all the movies which released in the country other
than UK.
mov_dt_rel AS Date_of_Release,
mov_rel_country AS Releasing_Country
FROM movie
WHERE mov_rel_country<>'UK';
4. Write a query in SQL to find the movie title, year, date of release, director and
actor for those movies which reviewer is unknown.
act_fname, act_lname
WHERE a.mov_id=b.mov_id
AND b.dir_id=c.dir_id
AND a.mov_id=d.mov_id
AND d.rev_id=e.rev_id
AND a.mov_id=g.mov_id
AND g.act_id=f.act_id
5. Write a query in SQL to find the titles of all movies directed by the director whose
first and last name are Woddy Allen.
SELECT mov_title
FROM movie
WHERE mov_id=(
SELECT mov_id
FROM movie_direction
WHERE dir_id=(
SELECT dir_id
FROM director
));
6-Write a query in SQL to find all the years which produced at least one movie and
that received a rating of more than 3 stars. Show the results in increasing order.
FROM movie
WHERE mov_id IN (
SELECT mov_id
FROM rating
WHERE rev_stars>3)
ORDER BY mov_year;
7-Write a query in SQL to find the titles of all movies that have no ratings.
FROM movie
WHERE mov_id IN (
SELECT mov_id
FROM movie
FROM reviewer
WHERE rev_id IN (
SELECT rev_id
FROM rating
9. Write a query in SQL to return the reviewer name, movie title, and stars for those
movies which reviewed by a reviewer and must be rated. Sort the result by reviewer
name, movie title, and number of stars.
WHERE reviewer.rev_id=rating.rev_id
AND movie.mov_id=rating.mov_id
10. Write a query in SQL to find the reviewer's name and the title of the movie for
those reviewers who rated more than one movies.
WHERE rating.mov_id=movie.mov_id
AND reviewer.rev_id=rating.rev_ID