Question

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 studio of the most expensive movie of each year (note: again, there can be ties in any given year!).

3. Find, for each actor, the number of movies by studio MGM that the actor has appeared in. Note: if an actor has not appeared in any movie by MGM, there is no need to list the actor.

4. Find the number of movies per country (using nationality of any actor in the movie). Note: you shouldn’t count movies twice; if two or more actors from a country have appeared in a given movie, make sure to count that movie only once.

5. Find the names of directors who have never directed a comedy.

6. List the titles of movies where all actors were British.

7. List the titles and director names of movies where the sum of the salaries of all actors in the movie was more than the movie budget.

8. Find out, in each movie, what percentage of the budget went to pay the top paid actor in that movie. You can assume there is only 1 top paid actor per movie.

Homework Answers

Answer #1

SQL QUERIES:

1.

SELECT title, director-name, studio, MAX(BUDGET)  

FROM movie

WHERE year= 2010;

EXPLANATION:

Maximum budget is selected using MAX() function where year= 2010

2.

SELECT title, director-name, studio, year, MAX(BUDGET)  

FROM movie

GROUP BY year;

EXPLANATION:

Group by year is used to result maximum budget for each year.

3.

SELECT a.name, COUNT(a.title)

FROM Appears a, movie m

WHERE a.title= m.title

AND m.studio= 'MGM';

4.

SELECT ac.nationality, COUNT(DISTINCT ap.title) AS "No. Of movies"

FROM ACTOR ac, APPEARS ap

WHERE ac.name= ap.name;

GROUP BY ac.nationality;

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 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...
***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...
Movie Database This database features two entities (MOVIES and ACTORS) in a many-to-many relation. Each entity...
Movie Database This database features two entities (MOVIES and ACTORS) in a many-to-many relation. Each entity has its own table. A third table, CASTING, is used to link them. The relationship is many-to-many because each film features many actors and each actor has appeared in many films. One possible state of the database is shown. MOVIE id title yr director budget gross 10003 "Crocodile" Dundee II 1988 38 15800000 239606210 10004 'Til There Was You 1997 49 10000000 ACTOR id...
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...
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.)....
This assignment allows students to demonstrate their skills in the area of designing relational databases to...
This assignment allows students to demonstrate their skills in the area of designing relational databases to satisfy specific business rules and requirements. The deliverables for this assignment include an Entity Relationship Diagram and detailed documentation describing the database design and structure. In this assignment, you will be provided with a description of an application (below) to create an entity-relationship diagram (ERD) and design accompanying table layout using sound relational modeling concepts and practices. The relationships between the entities and the...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode)...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). A research field...