You are on page 1of 2

Consider the following relational database with two relations.

Parks Name Grand Canyon Petrified Forest Yellowstone Yellowstone Yellowstone States Name Arizona Idaho Montana Wyoming State Arizona Arizona Idaho Montana Wyoming Capital Phoenix Boise Helena Cheyenne Area 1902 342 3468 3468 3468 Population 5130632 1293953 902195 493782 Year 1919 1962 1872 1872 1872 Abbreviation AZ ID MT WY

Answer the following questions: 1. Represent the data above using XML format. Group the parks according to the states that they belong to. Specifically, every node park must have an element node state as its parent or an ancestor. A park node should not have descendants describing its state information. Name this XML document as sample.xml (3 pts). 2. Write XQuery (http://www.w3.org/TR/xquery/) to express the following searches. If you would like to test your queries, you may download and install XML Spy, at http://www.altova.com/download/xmlspy/xml_editor_enterprise.html (72 pts). (a) Find the name and year information of the parks in the state of Arizona. (b) For every park in the state of Montana, list all the state names that they are associated with. (c) List all the parks (the entire element) in the descending order of their area sizes. (d) Find the names of the states that have at least two parks founded before year 1970. (e) Find the number of the distinct parks in the XML document. (f) Find the name of the states that have the largest number of parks. 3. Design XML schema for the above XML data (which groups parks according to states).

Suppose that we know the following key constraints on the data: (1) we can uniquely identify a state among all the states in the document by its name; (2) we can uniquely identify a park among all the parks in the document by its name. Is it possible to express these two constraints in XML schema? If so, express them in the XML schema; if not, explain why (25 pts).

You might also like