Practice Exercises: Doctype Element Element Element Element Pcdata Pcdata

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CHAPTER

30
XML

Solutions for the Practice Exercises of Chapter 30

Practice Exercises

30.1 Write a query in XQuery on the XML representation in Figure 30.11 to find the
total salary of all instructors in each department.
30.2 Write a query in XQuery on the XML representation in Figure 30.1 to compute
the left outer join of department elements with course elements. (Hint: Use
universal quantification.)
30.3 Write queries in XQuery to output course elements with associated instructor
elements nested within the course elements, given the university information
representation using ID and IDREFS in Figure 30.11.
30.4 Give a relational schema to represent bibliographical information specified
according to the DTD fragment shown below:

<!DOCTYPE bibliography [
<!ELEMENT book (title, author+, year, publisher, place?)>
<!ELEMENT article (title, author+, journal, year, number, volume, pages?)>
<!ELEMENT author ( last name, first name) >
<!ELEMENT title ( #PCDATA )>
⋯ similar PCDATA declarations for year, publisher, place, journal, year,
number, volume, pages, last name and first name
]>

The relational schema must keep track of the order of author elements. You
can assume that only books and articles appear as top-level elements in XML
documents.
11
12 Chapter 30 XML

30.5 Show the tree representation of the XML data in Figure 30.1, and the represen-
tation of the tree using nodes and child relations described in Section 30.6.2.
30.6 Consider the following recursive DTD:
<!DOCTYPE parts [
<!ELEMENT part (name, subpartinfo*)>
<!ELEMENT subpartinfo (part, quantity)>
<!ELEMENT name ( #PCDATA )>
<!ELEMENT quantity ( #PCDATA )>
]>

a. Show how to map this DTD to a relational schema. You can assume
that part names are unique; that is, wherever a part appears, its subpart
structure will be the same.
b. Create a schema in XML Schema corresponding to this DTD.

You might also like