40 likes | 54 Views
CPSC 534B – Assignment 3. Question 1. Consider the spreadsheet containing quarterly sales figures for each salesman, along with annual totals. Devise a DTD for publishing this data in XML. What are the integrity constraints you can infer from your DTD?
E N D
CPSC 534B – Assignment 3 Question 1. Consider the spreadsheet containing quarterly sales figures for each salesman, along with annual totals. Devise a DTD for publishing this data in XML. What are the integrity constraints you can infer from your DTD? Suppose the spreadsheet data is published according to your DTD. Now, write a query in XQuery to transform this data into a format conforming to (the DTD for) relational format. How are the integrity constraints transformed? Repeat the whole exercise with XML schema.
Question 2. This question concerns XPath. As illustrated in class, backward axes can sometimes be removed from XPath expressions, by rewriting them into equivalent ones. E.g., /book/*[parent:*/isbn]/author can be rewritten into: /book[isbn]/*/author. In this question, you are asked to come up with general criteria for rewriting XPath expressions into ones not involving backward axes. Using your criteria, can you develop an algorithm for rewriting? With the aid of DTD knowledge, we can turn more XPath expressions into those free of backward axes. Give an example illustrating this. Can you develop DTD-specific criteria for when such a rewriting is possible? Check whether your algorithm is complete (in either case). Why (not)?
Question 3. We discussed several structural join algorithms in class. Can you modify these algorithms so as to compute the following operations: • Structural semi-join. • Structural semi-antijoin. • Structural (left) outerjoin. In each case, establish the time and space complexity of your modified algorithms.
Question 4. Translate the following XQuery statement into an equivalent TAX expression (the major steps for a very similar query were actually outlined in class!): FOR $a IN distinct(document(“mybib.xml”)//author) WHERE $a/@hobby = “tennis” AND $a/affiliation=“UBC” RETURN <ubc-author-books> {$a/name} {FOR $b IN document(“mybib.xml”)//book WHERE $b/author = $a RETURN $b/title} </ubc-author-books>