Xquery (2) : Exercise 1: Writing Queries in Xquery
Xquery (2) : Exercise 1: Writing Queries in Xquery
Peter Fischer Lecuture XML and Databases Winter Semester 2011/12 Due date/discussion: 16.12.2011 Exercise Sheet 7
XQuery (2)
Exercise 1: Writing queries in XQuery Consider the XML document distributed together with this exercise (exercise6-1.xml validated against exercise6-1.xsd). It corresponds to the model created for Exercise sheet 3 (XML Schema). Write the XQuery expression for solving the following problems. Your results should be well-formed XML. 1.1. Give the list of the direct flights on the date of 2009-12-24 which have "North Pole" (airport name) as the source airport. 1.2. Retrieve the list of the busiest airports on the date of 2009-12-24 (based on the number of departures and arrivals). 1.3. Identify all the flight destinations of Passenger "Santa Claus". 1.4. Consider the case of combined flights (two or more). As an example, flying from London to Zurich on the date of 2008-12-24 might mean taking two separate flights: London-Amsterdam and Amsterdam Zurich, both on the same date. Retrieve all flight possibilities from "North pole" to "South pole"on the date of 2009-12-24 with one or two intermediate stops. Note that the schema was enhanced with departure and arrival times. Exercise 2: Element constructors and node identities 2.1. Given is the following XQuery expression:
let $a := <a/> let $b := <b>{$a}</b> return $b/a is $a
Is the result true, false, or an error? Explain the result. 2.2. As a comparison, what is the result of the following expression?
let $a := <a/> let $b := $a return $b is $a
Exercise 3: Launching your queries Use Oxygen or the XQuery Development Tools http://www.xqdt.org) to run the queries on your instance!
(a
plugin
for
Eclipse,