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
***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...
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...
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...
#########################PANDAS LANGUAGE################## #########################MATPLOT LIB######################### # filter the movies with specific actor's name ​# List of top...
#########################PANDAS LANGUAGE################## #########################MATPLOT LIB######################### # filter the movies with specific actor's name ​# List of top 5 Actor per year who has highest rating from the year 2010 - 2017 ​# plot horizontal barcahrt of upper output # visualize those to 10 runtime of movies ​# visualize those to 10 runtime which has highest rating of movies ​# show count all movies which has rating more 3.0 and less than 7.0​ # plot vertical barchart of upper output, movies w.r.t...
Q1. Use Union statements to show the following: list the number of artists that have a...
Q1. Use Union statements to show the following: list the number of artists that have a webaddress, the number of artists that do not have a webaddress, and the total number of artists. The output should look like: +--------------------------+----------+ | Has webaddress | count(*) | +--------------------------+----------+ | Has webaddress | 5 | | Does not have webaddress | 6 | | Total | 11 | +--------------------------+----------+ Q2. A new salesperson has been hired. Their SalesID is 5, full name is...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT