DOC PREVIEW
Rutgers University CS 336 - Homework Two Due at the Start of Class/Recitation

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

198:336 Spring 2005Homework TwoDue at the Start of Class/RecitationWednesday, March 9This homework is just to do exercises 5.2 and 5.4 from the textbook: Ramakrishnan andGehrke. In the third edition, the problems can be found on pages 175–177. This just repeatsthe problem statement, for those of you who may not have been able to get the up-to-date editionof the book.For those of you interested in testing out the queries—and that should be most of you—theschemas and data have been uploaded to the department Oracle server. Instructions for accessingOracle are available on the course web site.If you have another database platform you prefer to use, detailed instructions for setting upthese schemas and data are available through the book’s webpage athttp://www.cs.wisc.edu/˜dbbookProblem 5.2Consider the following schema:suppliers(sid: integer, sname: string, address: string)parts(pid: integer, pname: string, color: string)catalog(sid: integer, pid: integer, cost: real)The catalog relation lists the prices charged for parts by suppliers. These relations are available onour Oracle server as mdstone.suppliers, mdstone.parts and mdstone.catalog.Write the following queries in SQL:1. Find the pname of parts for which there is some supplier.2. Find the snames of suppliers who supply every part.3. Find the snames of suppliers who supply every red part.4. Find the pnames of parts supplied by Acme Widget Suppliers and no one else.5. Find the sids of suppliers who charge more for some part than the average cost of that part.6. For each part, find the sname of the supplier who charges the most for that part.7. Find the sids of suppliers who supply only red parts.8. Find the sids of suppliers who supply a red part and a green part.9. Find the sids of suppliers who supply a red part or a green part.110. For every supplier that only supplies green parts print the name of the supplier and the totalnumber of parts that she supplies.11. For every supplier that supplies a green part and a red part, print the name and price of themost expensive part that she supplies.Problem 5.4Consider the following relational schema. An employee can work in more than one department;the pct time field of the works relation shows the percentage of time that a given employee worksin a given department.emp(eid: integer, ename: string, age: integer, salary: real)dept(did: integer, budget: real, managerid: integer)works(eid: integer, did: integer, pct time: integer)These relations are visible on Oracle as mdstone.emp, mdstone.dept and mdstone.works.Write the following queries in SQL:1. Print the names and ages of each employee who works in both the Hardware department andthe Software department.2. For each department with more than 20 full-time equivalent employees print the did togetherwith the number of employees that work in that department.3. Print the name of each employee whose salary exceeds the budget of all of the departmentsthat he or she works in.4. Find the managerids of managers who manage only departments with budgets greater than$1 million.5. Find the enames of managers who manage the departments with the largest budgets.6. If a manager manages more than one department, he or she controls the sum of all the budgetsfor those departments. Find the managerids of managers who control more than $5 million.7. Find the managerids of managers who control the largest amounts.8. Find the enames of managers who manage only departments with budgets larger than $1million, but at least one dept with budget less than $5


View Full Document

Rutgers University CS 336 - Homework Two Due at the Start of Class/Recitation

Download Homework Two Due at the Start of Class/Recitation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework Two Due at the Start of Class/Recitation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework Two Due at the Start of Class/Recitation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?