


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Mingsong Chen Wenjie Yuan
Name: UFID: Email Address:
Pledge (Must be signed according to UF Honor Code)
On my honor, I have neither given nor received unauthorized aid in doing this assignment.
_______________________________________________Signature
For scoring use only:
Maximum Received
Exercise 1 40
Exercise 2 30
Exercise 3 30
Total 100
Given the following relations:
Customers (cid, cname, city, discnt) Agents (aid, aname, city, percent) Products (pid, pname, city, quantity, price) Orders (ordno, month, cid, aid, pid, qty, dollars)
Write the following queries in SQL:
customers FROM that agent.
orders rows with cid=x and pid=y. Is it possible in a single SQL statement to retrieve cid values of customers who order all the products that they receive in average quantities (by product) of at least 300?
Dallas.
based in Duluth or Kyoto.
only through agent a04. On the same line with each cid, your query should list the total dollar amount of orders placed.
customers who live in Duluth. The aid values should be reported in order by decreasing percent. (Note that if percent is not retrieved in the SELECT list, we cannot order by these values.)
in the same city as the agent taking the order.
Consider 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 key fields are underlined, and the domain of each field is listed after the field name. Therefore sid is the key for Suppliers, pid is the key for Parts, and sid and pid together form the key for Catalog. The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries in relational algebra, tuple relational calculus, and domain relational calculus: