Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A movie can have 0 or more actors A movie can have 1 or more categories A movie has 1 and only one language Rating
A movie can have 0 or more actors A movie can have 1 or more categories A movie has 1 and only one language Rating is one of these values: 'G','PG','PG-13','R', 'NC-17' People can comment about the movies in a webpage, and the comments are stored in the comments table. The reviewer_name is introduced by the person on each comment, so we don't have a table with reviewers". A reviewer can create any number of comments about a movie The comments will have a score about the movie with values from 0 to 100. Note, the last update fields are going to be stored as a "timestamp" IMPORTANT: 2 entries in the same relation can have the same lastupdate, so, for example, 2 movies can have the same lastupdate value. The relations are: ACTOR (actor_id, first_name, last_name, last_update) LANGUAGE (language_id, name, last_update) CATEGORY (category_id, name, last_update) FILM (film_id, title, description, release_year, language_id, length, rating, last_update) FILM_ACTOR(actor_id, film_id, last_update) FILM_CATEGORY (film_id, category_id, last_update) COMMENTS (review_id, film_id, reviewer_name, comment score, last_update) Your queries must not be "state-dependent", that is, they should work without modification even if another instance of the database is given or if the ID's change. That means don't use directly specific ID's in the query, the query will need to find the ID's based in the data provided. For example: If the data in the question is the Movie Title, we don't know a priori the ID of that movie, we will need to write the query in a way that is able to use the movie title, and not directly the ID NOTE: THIS IS SQL, NOT RELATIONAL ALGEBRA. Any answer provided in RELATIONAL ALGEBRA will be graded with a 0. Your queries must not be "state-dependent", that is, they should work without modification even if another instance of the database is given or if the ID's change. That means don't use directly specific ID's in the query, the query will need to find the ID's based in the data provided. For example: If the data in the question is the Movie Title, we don't know a priori the ID of that movie, we will need to write the query in a way that is able to use the movie title, and not directly the ID NOTE: THIS IS SQL, NOT RELATIONAL ALGEBRA. Any answer provided in RELATIONAL ALGEBRA will be graded with a 0. 5. (5 points) Find all the movie titles where and actor called "JOHN" OR an actor called "BEN acted, where there was another actor called "MARY" acting too. (That means movies with JOHN and MARY, movies with BEN and MARY and movies with JOHN, BEN and MARY) 6. (5 points) Find the reviewers that have reviewed movies in all the categories. 7. (5 points) Movies have a length in minutes. Show a list with all the lengths ordered from longer to shorter, and the number of movies for each of the lengths. 8. (5 points) Show the 5 categories with the longer average length (show the name of the category and the average length of the movies for each category) order by average length from longer to shorter and in case of "tie" ordered by category name in alphabetical order. A movie can have 0 or more actors A movie can have 1 or more categories A movie has 1 and only one language Rating is one of these values: 'G','PG','PG-13','R', 'NC-17' People can comment about the movies in a webpage, and the comments are stored in the comments table. The reviewer_name is introduced by the person on each comment, so we don't have a table with reviewers". A reviewer can create any number of comments about a movie The comments will have a score about the movie with values from 0 to 100. Note, the last update fields are going to be stored as a "timestamp" IMPORTANT: 2 entries in the same relation can have the same lastupdate, so, for example, 2 movies can have the same lastupdate value. The relations are: ACTOR (actor_id, first_name, last_name, last_update) LANGUAGE (language_id, name, last_update) CATEGORY (category_id, name, last_update) FILM (film_id, title, description, release_year, language_id, length, rating, last_update) FILM_ACTOR(actor_id, film_id, last_update) FILM_CATEGORY (film_id, category_id, last_update) COMMENTS (review_id, film_id, reviewer_name, comment score, last_update) Your queries must not be "state-dependent", that is, they should work without modification even if another instance of the database is given or if the ID's change. That means don't use directly specific ID's in the query, the query will need to find the ID's based in the data provided. For example: If the data in the question is the Movie Title, we don't know a priori the ID of that movie, we will need to write the query in a way that is able to use the movie title, and not directly the ID NOTE: THIS IS SQL, NOT RELATIONAL ALGEBRA. Any answer provided in RELATIONAL ALGEBRA will be graded with a 0. Your queries must not be "state-dependent", that is, they should work without modification even if another instance of the database is given or if the ID's change. That means don't use directly specific ID's in the query, the query will need to find the ID's based in the data provided. For example: If the data in the question is the Movie Title, we don't know a priori the ID of that movie, we will need to write the query in a way that is able to use the movie title, and not directly the ID NOTE: THIS IS SQL, NOT RELATIONAL ALGEBRA. Any answer provided in RELATIONAL ALGEBRA will be graded with a 0. 5. (5 points) Find all the movie titles where and actor called "JOHN" OR an actor called "BEN acted, where there was another actor called "MARY" acting too. (That means movies with JOHN and MARY, movies with BEN and MARY and movies with JOHN, BEN and MARY) 6. (5 points) Find the reviewers that have reviewed movies in all the categories. 7. (5 points) Movies have a length in minutes. Show a list with all the lengths ordered from longer to shorter, and the number of movies for each of the lengths. 8. (5 points) Show the 5 categories with the longer average length (show the name of the category and the average length of the movies for each category) order by average length from longer to shorter and in case of "tie" ordered by category name in alphabetical order
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started