CSE 391
Spring 2004
Stony Brook
Web Queries: Methods and Tools
Annie Liu
Assignment 3
Handout A3
Feb. 17, 2004
Due Mar. 4

XML Queries

This homework is on XML queries using XQuery, and optionally XSLT and SQL/XML for extra credits, for the same database application described in Assignment 2.

Please refer to the kinds of data, constraints, and queries described in Handout A2.

For this assignment, you are asked to write XQuery code for each kind of queries as well as for each kind of constraints that you could not enforce using XML Schema in Assignment 2; each such constraint should be expressed as an XQuery query so that the constraint is considered violated if the corresponding query returns a non-empty answer (this approach is analogous to assertions in SQL).

You also need to prepare sample XML data. It is your responsibility to come up with reasonable test data. If your data consists of just a few items that do not illustrate the queries well, your grade will be affected accordingly.

You are asked to run and test your queries using Quip (installed on machines in the translab).

It is OK if you need to change the XML representation of your data for better (easier, more efficient, etc.) queries and thus change the schema files from Assignment 2. Make sure you do validity checks after the change, include the updated schema files in your handins, and document the reason and effort for the change.

Besides the code and sample data, you should also document the effort and result of your design (including important considerations and comparison among alternatives that you thought of, if any) and redesign (if needed) as well as your effort and results of using Quip and other tools (if any).


Before class on the due date, send your completed homework to cse391@cs.sunysb.edu (not to the instructor or TA). If there is more than one file in your homework, please zip the files before you send. There should be one file (either the README file, or the single file for your homework) that contains a description of where is what and instructions for how to test your homework.

Also, in class, hand in a printout that contains the documentation part of your work. You do not need to print out code and data.


This homework is worth about 6% of the course grade. Exceptionally well thought-out and well written homeworks will receive appropriate extra credit.


Write the queries using XSLT, and test them using XMLSPY. As always, don't forget to include documentation. (30% extra credit)

Write the queries using SQL/XML, and include your design and SQL/XML for putting your XML data into a relational DB. (20% extra credit)