|
Due Thursday May 13th |
To fully test your functionality, and to simulate the true operation of an online auction system in which auctions close as time passes, we suggest that you maintain a fictitious "current time" in your database. Add a new one-attribute table to your AuctionBase schema. This table should at all times contain a single row (i.e., a single value) representing the "current time," which can be updated to represent time passing. (It's up to you whether you also want to permit backward time-travel.) Initialize the table by inserting the current time for the initial state of your database: Dec-20-01 00:00:01.
Note: If you want to input and output dates in Oracle using the same format as in the original XML auction data files, issue the command:
alter session set NLS_DATE_FORMAT='MON-DD-YY HH24:MI:SS';For more information see the Oracle Dates and Times help document.
Create a file named time.sql that contains your commands for creating and initializing your current time table.
For this part, you will be writing a procedure that computes the "bidding closure" for a specified seller. More precisely, given a particular seller as a parameter, we wish to construct the set of all bidders who placed a bid on one of the seller's items, or (recursively) on an item being sold by any of the bidders in this set. For example, if we wish to compute the recursive bidding closure of seller Jennifer, and Beverly placed a bid on one of Jennifer's items, and Qi placed a bid on one of Beverly's items, then Beverly and Qi would be in the recursive bidding closure of Jennifer. Note that Jennifer is not part of this closure.
Your procedure, called compute_closure, should take as an argument the user id of a seller, and it should insert into a relation called my_closure the user id's of the individuals in the seller's bidding closure.
Please create a command file named closure.sql containing the command to create your closure relation, your PL/SQL procedure, and a command for invoking your procedure with some parameter. To facilitate the grading process, your closure.sql file must have the following format:
drop procedure compute_closure;
drop table my_closure;
create table my_closure ( ... );
create procedure compute_closure ( ... )
...
end;
.
run;
begin
compute_closure( ... );
end;
.
run;
select count(*) from my_closure;
drop procedure compute_closure;
drop table my_closure;
quit;
The DROP commands are for cleaning up before and after you
run your procedure. You should fill in the details of creating your
closure relation, the actual procedure, and calling your procedure. Be
sure to test your procedure thoroughly.
Correctness check: When you run your procedure for seller 'westbur' using the large data set, your bidding closure should contain 87 rows.
Please be very careful to note that constraints and triggers as supported in Oracle do not conform to the SQL-99 standard, the lecture notes, or the textbook. You will need to read the help document carefully.
If the data in your AuctionBase system at a given point in time represents a correct state of the real world, a number of constraints are expected to hold. To get you started, here are a few possible examples, some of which depend on a particular schema:
For all cases other than triggers and referential integrity with an "on delete" option, an error is raised automatically whenever a constraint is violated. For triggers, raise an error with the function RAISE_APPLICATION_ERROR as described in the Constraints and Triggers help document.
alter table ... drop constraint ... ;
alter table ... add constraint ... ;
insert/delete/update ... ; /* modification where the constraint fails */
insert/delete/update ... ; /* modification where the constraint holds */
alter table ... drop constraint ... ;
quit;
You should fill in the details of the constraint and the
modifications. Make sure you put the modification that fails the
constraint first. Some notes:
Run your constraint-checking queries. If any constraints do not hold, then either your constraints are inappropriate or your database is in an inconsistent state. Stop now and fix the problem!
For each constraint, find at least one modification where a trigger is activated, detects a constraint violation, and raises an error. Also find at least one modification where one or more triggers are activated but the constraint holds so no error is raised -- for each activated trigger, the WHEN condition fails, or the trigger action detects that the constraint holds.
When you have fully tested your triggers, create a separate command file for each of your constraints that is being enforced by triggers. The command file should have the following format:
drop trigger ... ;
drop trigger ...; /* if constraint requires more than one trigger */
...
create trigger ...;
create trigger ... ;
...
select ... ; /* query verifying constraint on current database */
insert/delete/update ... ; /* modification that fails */
insert/delete/update ... ; /* modification that succeeds */
drop trigger ... ;
drop trigger ...;
...
quit;
You should fill in the details of the trigger statements,
constraint-checking query, and database modifications. Make sure your
select query for verifying the constraint on the current
database returns an empty result if and only if the constraint
holds. Remember to put the modification that fails the constraint
first. Name the command files for your two constraints enforced by
triggers trigger1.sql and trigger2.sql. If you
submit additional constraints enforced by triggers (no extra credit!)
call the files trigger3.sql, trigger4.sql, etc.
| time.sql | Command file for creating and initializing the time table as specified in Part A | |
| closure.sql | Command file for PL/SQL as specified in Part B | |
| constraints.txt | Constraints file as specified in Part C | |
| referential.sql | Command file for a referential integrity constraint | |
| check.sql | Command file for a check constraint | |
| trigger1.sql | Command file for a first trigger-based constraint | |
| trigger2.sql | Command file for a second trigger-based constraint |
One exception is that you may submit additional referential, check, and trigger command files as described earlier.
Important: If you decided to change your database schema while doing this part of the project, you must also resubmit ALL of the relevant files from Project Part 1: parser, Makefile, runParser script, control files, etc.. Refer back to the Project Part 1 Specification for details on the files to submit.
As usual, from your submission directory execute the script:
/afs/ir/class/cs145/bin/submit-projectYou may resubmit as many times as you like, however only the latest submission and timestamp are saved, and those are what we will use for grading your work and determining late penalties. Submissions via email will not be accepted.
Note: Points will be deducted if you do not follow the submission procedures exactly as specified, including which files to include (and which not to include), file naming, and file contents. Remember to allow sufficient time to prepare your submission once your work is complete.