Question

I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...

I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL:

1) Find the actors that have movies in all the categories.

2) Movies have a length in minutes. Show a list with all the lengths ordered from shorter to longer, and the number of movies for each of the lengths.

3) Show the 10 first results with the first name, last name and average length of the movies for each actor order by actor first name, and actor last name.

Schema:

Consider a movie relational database schema description provided below which is used to manage a movie database, where:

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 on 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)

Homework Answers

Answer #1

If you have any doubts, please give me comment...

-- 1

SELECT *

FROM FILM_ACTOR AS FA

WHERE NOT EXISTS(

SELECT *

FROM CATEGORY C

WHERE NOT EXISTS(

SELECT *

FROM FILM_CATEGORY AS FC

WHERE FA.film_id = FC.film_id AND C.category_id = FC.category_id

)

);

-- 2

SELECT `length`, COUNT(*) AS noOfMovies

FROM FILM

GROUP BY `length`

ORDER BY `length`;

-- 3

SELECT first_name, last_name, AVG(length) AS avgLength

FROM ACTOR AS A, FILM_ACTOR AS FA, FILM AS F

WHERE A.actor_id = FA.actor_id AND FA.film_id = F.film_id

GROUP BY A.actor_id, first_name, last_name

ORDER BY first_name, last_name

LIMIT 10;

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL: 1) Find the actors that have movies in all the categories. 2) Movies have a length in minutes. Show a list with all the lengths ordered from shorter to longer, and the number of movies for each of the lengths. 3) Show the 10 first results with the first name, last name and average length of the movies for...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL: 1) Find all the Comments created by “Mike_34” with a score bigger than 80 2) Find the Film title from all the movies with an actor with first name “TOM”. 3) Find the full name of all the actors in the movies with at least a comment with a score equal to 100. Schema: Consider a movie relational database...
Write the following questions as queries in SQL. Use only the operators discussed in class (in...
Write the following questions as queries in SQL. Use only the operators discussed in class (in particular, no outer joins or windows). Type your answers. Before starting, make sure you understand the schema of the database. If you are in doubt about it, please ask the instructor. Assume a database with schema ACTOR(name,age,address,nationality) MOVIE(title,year,genre,budget,director-name,studio) APPEARS(name,title,salary) 1. Find the title, director and studio of the most expensive movie of 2010 (note: there can be ties!). 2. Find the title, director and...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the below Relational Database. • Regarding the SQL queries: • Do not use SELECT * in any query. • Do not use any SQL features (including Nullif) that were not covered in this course. • Do not use subqueries IF joins can be used to answer a question. However, some questions may require the use of subqueries. The Movie Database Notes: TheaterNum, MovieNum, and ActorNum...
The following describes the Universe of Discourse for the assignment: With the current popularity of video...
The following describes the Universe of Discourse for the assignment: With the current popularity of video streaming services like ‘Netflix’ and ‘Amazon Prime’, you have been tasked with creating a database for a new up-and-coming streaming service called ‘Home Cinema’. Each product on the site is classified as either a movie or TV show. For each product, the site stores it’s title, a unique code, a brief synopsis and a collection of tags related to it (Action, Adventure, Romance, etc.)....
You are a database consultant with Ace Software, Inc., and have been assigned to develop a...
You are a database consultant with Ace Software, Inc., and have been assigned to develop a database for the Mom and Pop Johnson video store in town. Mom and Pop have been keeping their records of videos and DVDs purchased from distributors and rented to customers in stacks of invoices and piles of rental forms for years. They have finally decided to automate their record keeping with a relational database. You sit down with Mom and Pop to discuss their...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in...
Using mySQL, tables at the end... This assignment uses the tables from the vets database. The...
Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goal of the assignment is to get you to think about joins- inner join and outer joins.  If you do a join, where you have the names of two or more tables in the From clause, then you must use the condition join syntax or the column name join. Take care that you do not accidentally do a Cartesian product. If your result set contains...