Midterm Review
Midterm Review
Consider a MOVIE database (like IMDB database) in which data is recorded about the
movie industry. The data requirements are summarized as follows:
• Each movie has a unique id, title, year produced, length in minutes and genre.
Movies may have more than one genre (action, comedy, ..).
• Actors are uniquely identified by SSN and have name, gender, address.
• Each actor plays in movies and movies have actors.
• Each studio has a ID, name and address.
• Directors have a SSN , gender and address. Directors direct one or more movies.
Each movie has exactly one director.
• For each movie, there is exactly one studio that owns it. Each studio owns a set of
movies (zero or more).
• For each movie, movie-goers can enter comments. Each comment has an id,
comment text and rating. When a movie is deleted, all comments about the movie
are also deleted.
Draw an ER diagram for MOVIE database and create a relational schema for it
Sample Relational Algebra on MOVIE DB
1. Find title of movies in which Jennifer Lawrence has acted.
2. Find title of movies in which are directed by a female director in
2021
3. Find name of actors who acted on an action film produced by
Warner Bros studios
4. Find name of actors who have played both in action and romantic
comedy film(s)
5. Find name of studios which did not produce any comedy movie in
2014
6. Find name of actors who played in all genre types
7. Find title of drama movies directed by Steven Spielberg in years
2000-2020
8. Find title of movies which are produced by a studio located in
New York
Sample SQL questions on MOVIE DB
1. Find number of movies acted for each actor
2. Find title of movies only male actors acted.
3. Find name of actors who played in some movie
with Tom Hanks
4. Find title of movies in which Jennifer Lawrence
and Bradley Cooper acted together
5. Find title and average rating for all movies,
order the list in descending averate rating
6. Find name of actors who did not play in any
action movie