Homework 2
CS422, Summer 2009

Due: Wednesday, July 22

Please upload your solutions to CSNS. Note that file uploading will be disabled automatically after 11:59PM of the due date, so please turn in your work on time.


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

Please put all the queries in an SQL script hw2-queries.sql, and make sure that each query is labeled with the exercise number, e.g.

-- 4.20 (a)
select ...

2. (30pt) Write triggers to enforce the following data constraints:

For this exercises please submit two SQL scripts: hw2-triggers.sql and hw2-drop.sql. hw2-triggers.sql should include the code to create the triggers, as well as some insert statements to test whether the triggers work properly. hw2-drop.sql should include statements to remove the triggers and the associated functions.