0% found this document useful (0 votes)
395 views6 pages

Ass02 - Querying The Movie Ratinsg Data

This document describes an assignment to write SQL queries to analyze a movie rating database. It provides the schema for the Movie, Reviewer, and Rating tables and sample data. It then lists 20 individual questions as problems to write SQL queries to analyze relationships in the data such as identifying highly rated movies, common reviewers, and differences in ratings over time. Students are instructed to submit all queries as a file by a deadline for grading.

Uploaded by

10bicsesali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
395 views6 pages

Ass02 - Querying The Movie Ratinsg Data

This document describes an assignment to write SQL queries to analyze a movie rating database. It provides the schema for the Movie, Reviewer, and Rating tables and sample data. It then lists 20 individual questions as problems to write SQL queries to analyze relationships in the data such as identifying highly rated movies, common reviewers, and differences in ratings over time. Students are instructed to submit all queries as a file by a deadline for grading.

Uploaded by

10bicsesali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

CS220 Database Systems Assignment # 2 Querying Movie Rating Data

Problem Description
You've started a new movie-rating website, and you've been collecting data on reviewers' ratings of various movies. There's not much data yet, but you can still try out some interesting queries. Here's the schema:

Movie ( mID, title, year, director )


English: There is a movie with ID number mID, a title, a release year, and a director.

Reviewer ( rID, name )


English: The reviewer with ID number rID has a certain name.

Rating ( rID, mID, stars, ratingDate )


English: The reviewer rID gave the movie mIDa number of stars rating (1-5) on a certain ratingDate.

CS220 Database Systems Assignment # 2 Querying Movie Rating Data Your queries will run over a small data set conforming to the schema. Each problem asks you to write a query in SQL. The database is given as below:
Movie mID 101 102 103 104 105 106 107 108 Title Gone with the Wind Star Wars The Sound of Music E.T. Titanic Snow White Avatar Raiders of the Lost Ark year 1939 1977 1965 1982 1997 1937 2009 1981 Director Victor Fleming George Lucas Robert Wise Steven Spielberg James Cameron <null> James Cameron Steven Spielberg rID 201 202 203 204 205 206 207 208 Reviewer name Sarah Martinez Daniel Lewis Brittany Harris Mike Anderson Chris Jackson Elizabeth Thomas James Cameron Ashley White

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

CS220 Database Systems Assignment # 2 Querying Movie Rating Data

Core Questions
1. Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order. 2. Find the titles of all movies that have no ratings. 3. 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. 4. 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. 5. For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time, return the reviewer's name and the title of the movie. 6. 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. 7. List movie titles and average ratings, from highest-rated to lowest-rated. If two or more movies have the same average rating, list them in alphabetical order. 8. Find the names of all reviewers who have contributed three or more ratings. (As an extra challenge, try writing the query without HAVING or without COUNT.)

CS220 Database Systems Assignment # 2 Querying Movie Rating Data

Challenge-level Questions
9. 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. 10. 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.) 11. Some directors directed more than one movie. For all such directors, return the titles of all movies directed by them, along with the director name. Sort by director name, then movie title. (As an extra challenge, try writing the query both with and without COUNT.) 12. Find the movie(s) with the highest average rating. Return the movie title(s) and average rating. (Hint: This query is more difficult to write in SQLite than other systems; you might think of it as finding the highest average rating and then choosing the movie(s) with that average rating.) 13. Find the movie(s) with the lowest average rating. Return the movie title(s) and average rating. (Hint: This query may be more difficult to write in SQLite than other systems; you might think of it as finding the lowest average rating and then choosing the movie(s) with that average rating.) 14. For each director, return the director's name together with the title(s) of the movie(s) they directed that received the highest rating among all of their movies, and the value of that rating. Ignore movies whose director is NULL.

CS220 Database Systems Assignment # 2 Querying Movie Rating Data

More Questions
15. Find the names of all reviewers who rated Gone with the Wind. 16. For any rating where the reviewer is the same as the director of the movie, return the reviewer name, movie title, and number of stars. 17. Return all reviewer names and movie names together in a single list, alphabetized. (Sorting by the first name of the reviewer and first word in the title is fine; no need for special processing on last names or removing "The".) 18. Find the titles of all movies not reviewed by Chris Jackson. 19. For all pairs of reviewers such that both reviewers gave a rating to the same movie, return the names of both reviewers. Eliminate duplicates, don't pair reviewers with themselves, and include each pair only once. For each pair, return the names in the pair in alphabetical order. 20. For each rating that is the lowest (fewest stars) currently in the database, return the reviewer name, movie title, and number of stars.

CS220 Database Systems Assignment # 2 Querying Movie Rating Data

Important Notes and Deliverables


The tables needed for this assignment have been created on your database server. You may create the same set of tables at your end on local PCs by running the following script file embedded in this file.

Your queries are executed using Oracle, so you must conform to the SQL constructs supported by Oracle. Unless a specific result ordering is asked for, you can return the result rows in any order. Upload the file containing all the queries on LMS till Tuesday, 01st November, 2013 11:00PM. Total marks of this assignment are 20. These points will be awarded only if your queries are clean and readable, and returns the desired results. Late submissions will not be considered and will be awarded zero marks.

You might also like