Laboratory Exercise 4

SQL: Full-Relation Operations

CMP 420: Database Systems
Lehman College, City University of New York
6 March 2003


Unix Commands

Each lab begins with several Unix commands that will be useful for completing today's lab and future labs and assignments. Try the following commands:

Full-Relation Operators

In Lab 2, we created a database that stored information about companies, products, and orders.  We then populated the database with information about orders and products from 9 companies.  Today's lab will use the same database and focus on using the full-relation operators discussed in Section 6.4.

Note:  this lab follows from Lab 2.  If you haven't completed Lab 2 or forgotten the queries you wrote for Lab 2, you will find this lab much easier if you know write all the queries from Lab 2.

For today's lab,
  1. List all orders that not been paid for.
    (Hint: look at the data file and figure out what is the value of the ord_paid field if the order hasn't been paid for.)
  2. List all orders that have been delivered.
  3. List the orders that have been delivered, but not paid for.  
    (Hint:  combine the two queries above using a full-relation operation.)
  4. Find all dates on which an order was placed.  List each date exactly once.
  5. Find each order and its quantity that exceeds the average order quantity for all orders.
    (Hint: Use the ideas in Query #3 from Lab 2.)


Final Comments

Before leaving the lab, you need to log out and shut down your computer. First, you should quit all applications. Then, go to the K menu in the bottom left hand corner and select Log Out. Choose the Shut Down option, and shut off the monitor when you're done.

Remember to pick up any files you sent to the printer and to take any personal belongings. It is difficult to get back into the lab later (since it's locked when not in use), so, it's worth making sure you haven't forgotten anything.