Write the queries in sql

Assignment Help PL-SQL Programming
Reference no: EM13188206

In this problem, we will consider a movie database with three tables:

MovieDirector(title, director, year)

MovieCast(title, actor, salary)

MovieReview(title, reviewer, score)

All attributes are strings except year, salary, and score, which are integers.

A- Write the following queries in SQL. To save you some writing, you may use the abbreviated schema MD(T,D,Y), MC(T,A,S), and MR(T,R,S). Write your queries so that the final answers will never include duplicates, but add the keyword DISTINCT only in cases where duplicates would otherwise be produced.

(a) Using subqueries in WHERE, find the directors who have also acted. Sort their names alphabetically.

(b) Without using subqueries in WHERE, find the actors who have never directed.

(c) Find the titles of all movies in the 1960's starring both Dustin Hoffman and Anne Bancroft.

(d) Without using EXCEPT, find the actors who starred in every movie directed by Kurosawa.

(e) Using SQL aggregates, find the titles of the movies with at least two reviews.

(f) Same as (e), but use subqueries in WHERE instead of aggregates.

(g) Same as (e), but do not use subqueries in WHERE or aggregates.

(h) Using SQL aggregates, find the titles of the movies with exactly one review.

(i) Same as (h), but do not use aggregates.

(j) For each reviewer, find the average scores of all his/her reviews. However, do not list reviewers who have given out scores less than 1.

(k) Let's define the rating of a movie to be the average score given to this movie by reviewers.

     Find title, rating, and year of production for each movie. Movies with higher ratings should be listed first, and among the movies with the same rating, newer movies should be listed first.

(l) Let's define the rating of a director to be the average rating of all his/her movies. Find the names and ratings of all directors who have directed movies starring Al Pacino.

(m) Is the following a correct solution for (l)? Why?

SELECT director, AVG(score)

FROM MovieDirector d, MovieReview r

WHERE d.title IN (SELECT title FROM MovieCast WHERE actor = 'Al Pacino')

AND d.title = r.title;

(n) For each actor, find the total salary he/she earned each year during 1995-1999.

B. Consider the same movie database above. Write SQL data modification statements to complete the following tasks.

(a) If a movie spends a total of more than $10,000,000 on its cast, put in a review by its director with a score of 10.

(b) For each movie, remove one of its reviews with the highest score. If this movie has more than one reviews with the same highest score, remove only one of them. If this movie has only one review, do not remove the review.

Reference no: EM13188206

Questions Cloud

Make a line plot showing a data set that fits this household : A group of nine students has a mean of 3.5 people per . Make a line plot showing a data set that fits this household.
Derive the residual demand curve : In the model of a dominant firm, assume that the fringe supply curve is given by Q = -1 +0.2P, where P is market price and Q is output. Demand is given by Q = 11-P. What will price and output be if there is no dominant firm Now assume that there is..
How much will be in the account after 60 years : suppose a dollar placed into an account triples every 12 years. How much will be in the account after 60 years?
Find what is the molar mass of the compound : prepared by dissolving 33.2 g of the compound in sufficient water to form 250 mL of solution. The solution has an osmotic pressure of 1.2 atm at 25 °C. What is the molar mass (g/mole) of the compound?
Write the queries in sql : Write your queries so that the final answers will never include duplicates, but add the keyword DISTINCT only in cases where duplicates would otherwise be produced.
What is the largest surface area : Find the radius and height of the open right circular cylinder of largest surface area that can be inscribed in a sphere of radius a.
Describe senator reids delivery style : 1. Describe Senator Reid's delivery style 2. What type of presentation is Senator Reid giving Is this the most effective style of presentation for this situation Why or why not
What are the pros and cons of organizational technique : what is chain command and what are the pros and cons of organizational technique what bennefits are provided by the use of specific chain of command and what issues might result
What is the key for r : What is the key for R? Decompose R into 2NF, then 3NF relations and what you know about the relation to show that this MD cannot violate 4NF

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  An er diagram for the system

An ER diagram for the system. Show all entities, relationships, cardinalities and optionalities. Also, include all intersection entities. You must use the Finkelstein methodology as per the study book and tutorials.

  Write sql commands to implement profile

Write SQL commands which would implement this profile. Next, write query that would list profile, profile resource name, and limit value for the new profile.

  Write down sql needed to create employee table

Write down SQL needed to create employee table containing the following data: employeeID, text, length of 5, primary key lastName, text, length of 25

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

  Create program to enter first and second number

Create a program that enters first and a second number. The first and second number that will be entered should be computed in halves, quarter, double, and square.

  Select distinct cmdclient

SELECT DISTINCT CMDclient.'Client Code SCA' as GuestCode, CMDextras.ArrivalDate as arr, CMDextras.DepartureDate as dep, CMDapr.FirstName as fname, CMDapr.Surname as lname

  Create report to display scr courses in alphabetical order

Create the detail report which will display all SCR courses in alphabetical order, with a course name and instructor name in the group header.

  Draw an entity-relationship diagram

Draw an Entity-Relationship Diagram (ERD) for the data storage requirements of a business described in the case study and Data Model Transformation.

  Write sql statement which creates stored procedure

Write SQL statement which creates stored procedure with one int input parameter. Stored procedure selects supplierId field and total of all Count field values for each group of supplierId's from Part table.

  Create a view named productsummary

Create a view named ProductSummary that uses the view you created in exercise 4. This view should return some summary information about each product.

  Write an update statement that modifies the row

Write an UPDATE statement that modifies the row you just added to the Categories table. This statement should change the ProductName column to "Woodwinds", and it should use the CategoryID column to identify the row.

  Script that creates and calls a function

Write a script that creates and calls a function named fnItemTotal that calculates the total amount of an item in the OrderItems table (discount price multiplied by quantity)

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd