Lab 1. SQL and PL/SQL
CS422, Summer 2009

Please put all the queries, stored procedures, and triggers in an SQL script file lab1.sql and upload it CSNS at the end of the lab. Note that file uploading will be disabled automatically after 8PM, so please turn in your work on time.


1. (15pt) Complete the following queries using the sample database Store (store-create.sql, store-drop.sql). Feel free to insert more records into the tables to test your queries, but do not use any views.

2. (10pt)  Create a table called restock. This table lists the products that need to be restocked, i.e. the quantity of the product is below a certain threshold, e.g. 5. This table has three fields: the id of the product, the quantity of the product, and a timestamp.

Create a trigger on the products table that performs the following operations: