PART II: Open Books and Notes

PART II: Open Books and Notes

<p>PART II: open books and notes</p><p>11. (10 points) Single underline the primary key, double underline every foreign key, and circle every candidate key for the following relations. A product could be made by more than one manufacturer with different cost and price. (Minus 1 point for each wrong answer)</p><p> customer (custid, custname, soucialsecurityno, address, country)</p><p>PK: custid FK: none CK: soucialsecurityno</p><p> salesperson (salpersid, salpersname, dob, soucialsecurityno)</p><p>PK: salpersid FK: none CK: soucialsecurityno</p><p> product (prodid, manufactrid, prodname, cost, price)</p><p>PK: prodid+manufactrid FK: manufactrid for manufacturer CK: none</p><p> sales (salesid, date, custid, salpersid, saleamount)</p><p>PK: salesid FK: custid for customer; salpersid for salesperson CK: none</p><p> salesitem (salesid, prodid, manufactrid, qty)</p><p>PK: salesid+prodid+manufactrid FK: salesid for sales; prodid+manufactrid for product CK: none</p><p> manufacturer (manufactrid, manufactrname, address, country)</p><p>PK: manufactrid FK: none CK: none</p><p>1 12. Given the following 6 relations:</p><p> customer (custid, custname, soucialsecurityno, address, country) salesperson (salpersid, salpersname, dob, soucialsecurityno) product (prodid, manufactrid, prodname, cost, price) sales (salesid, date, custid, salpersid, saleamount) salesitem (salesid, prodid, manufactrid, qty) manufacturer (manufactrid, manufactrname, address, country)</p><p>(a) (10 points) Use the relational algebra to list prodid, prodname, cost, price, manufactrname of those products that are made in the United States.</p><p> product join manufacturer where product.manufactrid = manufacturer. manufactrid giving T1 select T1 where country = ‘United States’ giving T2 project T2 over (prodid, prodname, cost, price, manufactrname) giving T3</p><p>(b) (10 points) Use the relational algebra to list the customer information of those customers who have purchased a computer.</p><p> sales join salesitem where sales.salesid = salesitem.salesid giving T1 T1 join product where T1.prodid = product.prodid and T1.manufactrid = product.manufactrid giving T2 select T2 where prodname = ‘computer’ giving T3 customer semijoin T3 where T3.custid = customer.custid giving T4</p><p>(c) (10 points) Use the relational algebra to list salpersid and salpersname of those salespersons who have not sold a product on 3/4/04.</p><p> select sales where date = ‘3/4/04’ giving T1 salesperson leftouterjoin T1 where T1.salpersid = salesperson.salpersid giving T2 select T2 where salesid = null giving T3 project T3 over (salpersid, salpersname) giving T4</p><p>2</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us