This problem set uses a movie-rating database. An SQL script to implement the database in MySQL and a printout are available in the attachments to this problem set. This is a very small dataset but it is enough for some interesting queries. Here's the schema:

Movie ( mID, title, year, director )
/*meaning: There is a movie with ID number mID, a title, a release year, and a director. SQL syntax for a comment */

Reviewer ( rID, name )
/*meaning: The reviewer with ID number rID has a certain name. */

Rating ( rID, mID, stars, ratingDate )
/*meaning: The reviewer rID gave the movie mID a number of stars rating (1-5) on a certain ratingDate. */

Implement the database in MySQL exactly as you did for the Widom College Application database in the Software setup.

Each problem asks you to write a query in SQL and execute it in MySQL. When you are satisfied with your results capture a screenshot for inclusion in your problem set submission.

  • Unless a specific result ordering is asked for, you can return the result rows in any order.
  • You are to translate the English into an SQL query which computes the desired result over all possible data for this database. It is possible that your SQL query gets a correct output but is, in fact, not correct. (For example, if the problem asks for a complex question which requires accessing all of the tables, but over our small data set, the condition is satisfied only by "Star Wars", then the SQL query "SELECT title FROM Movie WHERE title = 'Star Wars'" looks correct but will be marked incorrect because your SQL code doesn't reflect the actual question.)

1 - Find the titles of all movies directed by Steven Spielberg.

2 - Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order.

3 - Find the titles of all movies that have no ratings.

4 - Some reviewers didn't provide a date with their rating. Find the names of all reviewers who have ratings with a NULL value for the date.

5 - Write a query to return the ratings data in a more readable format: reviewer name, movie title, stars, and ratingDate. Also, sort the data, first by reviewer name, then by movie title, and lastly by number of stars.

6 - For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time, write a query which returns the reviewer's name and the title of the movie.

7 - For each movie that has at least one rating, find the highest number of stars that movie received. Return the movie title and number of stars. Sort by movie title.

8 - For each movie, return the title and the 'rating spread', that is, the difference between highest and lowest ratings given to that movie. Sort by rating spread from highest to lowest, then by movie title.

9 - Find the difference between the average rating of movies released before 1980 and the average rating of movies released after 1980. (Make sure to calculate the average rating for each movie, then the average of those averages for movies before 1980 and movies after. Don't just calculate the overall average rating before and after 1980.)

Widom Movies Database

Table Movie

mID Title year Director
101 Gone with the Wind 1939 Victor Fleming
102 Star Wars 1977 George Lucas
103 The Sound of Music 1965 Robert Wise
104 E.T. 1982 Steven Spielberg
105 Titanic 1997 James Cameron
106 Snow White 1937 NULL
107 Avatar 2009 James Cameron
108 Raiders of the Lost Ark 1981 Steven Spielberg

Table Reviewer

rID Name
201 Sarah Martinez
202 Daniel Lewis
203 Brittany Harris
204 Mike Anderson
205 Chris Jackson
206 Elizabth Thomas
207 James Cameron
208 Ashley White

Table Rating

rID mID stars ratingDate
201 101 2 2011-01-22
201 101 4 2011-01-27
202 106 4 NULL
203 103 2 2011-01-20
203 108 4 2011-01-12
203 108 2 2011-01-30
204 101 3 2011-01-09
205 103 3 2011-01-27
205 104 2 2011-01-22
205 108 4 NULL
206 107 3 2011-01-15
206 106 5 2011-01-19
207 107 5 2011-01-20
208 104 3 2011-01-02

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.