


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The homework assignment for cps 116 fall 2004, including 3 problems related to xml programming and database management. Problem 1 requires completing a gradiance homework titled 'homework 3.1 (xml basics)'. Problem 2 involves writing xquery queries to answer questions about an xml document modeling data from an internet auction site. Problem 3 requires converting an xml document describing a thesaurus into a new format and designing a relation schema to store the thesaurus data.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



CPS 116 Fall 2004 Homework #3 (8.75% of course grade: 100 points) Assigned: Thursday, October 21 Due: Tuesday, November 2
Problem 1 (10 points).
Complete the Gradiance homework titled “Homework 3.1 (XML Basics).”
Problem 2 (56 points).
Consider an XML document (from a project called XMark) modeling the data maintained by an Internet auction site in /home/dbcourse/examples/xml-xmark/auction.xml. The main entities modeled are: items, persons, open auctions, closed auctions, and categories.
regions people open_auctions closed_auctions
{africa,asia,...}
iteminfo description
address
name
street
person name
city country
zipcode
open_auction bidder itemref seller date time personref
increase
initial
closed_auction itemref buyer seller
price
incategory
Fire up QuiP’s GUI and type in the following query
Write queries in XQuery to answer the following questions. You may test your queries in QuiP’s GUI, but please use the batch mode to generate the output to turn in. Because QuiP does not have a sophisticated optimizer, query performance may be heavily influenced by the way you write your queries. If a particular query takes forever to run, consider reordering loops and evaluating selections (filters) as early as possible.
For each question below, say (a), write your XQuery in a file named hw3-1-a.xquery, and generate the output file hw3-1-a.xml by running quip hw3-1-a.xquery > hw3-1- a.xml. Turn in printout of all your .xquery and output .xml files. If the output file is too long, print out only the first page of the output.
(a) Find names of all items in “namerica” region. (b) Find names of all items that belong to “category0.” (c) Find names of all persons whose address is in “United States.” (d) Find all buyers who paid for more than $50 in a closed auction. (Note: To get this query working, you might want to consult the “QuiPified” XQuery examples presented in lecture, which can be downloaded from the course Web site under the “Lecture Notes” section.) (e) Find names of all person who has bidden in an open auction for an item whose name contains the string “cow.” (Note: To use the XPath built-in function contains() in QuiP, you need to convert any node argument to a string explicitly, e.g., contains(string(name), “cow”).) (f) Find names of all persons with address in “United States” who never bought anything in closed auctions. (g) For each open auction whose seller's name is “Venkatavasu Takano,” print out the following information: <open_auction id=“...”>
Problem 3 (34 points).
Consider an XML document describing a thesaurus (from http://zthes.z3950.org/) in /home/dbcourse/examples/xml-zthes/thatt.xml. The XML document contains a list of terms. Each term has a list of relations with other terms. For example, the following excerpt
You must implement two out of the four options. For each option you implement, turn in a printout of the source code and the first twenty term elements in the result of transforming thatt.xml. Show the raw output generated by your code; do not manually edit the output (other than truncating it for printout).
(b) (14 points.) Design and create a relation schema to store the thesaurus data using the schema-aware approach discussed in lecture. Your design should not have the redundancy described in (a). Populate the tables with the data from thatt.xml. You should write a program or script to convert the data into flat files and import them into DB2. Do not use individual INSERT statements. The choice of programming/scripting language and XML API is up to you. Instructions on how to load a DB2 database can be found in the document “DB2 SQL Programming Notes” on the course Web site; examples can be found in /home/dbcourse/examples/db- */ directories.
Turn in the following: