CS145 - Spring 2003
Introduction to Databases

Online (OTC) Account Information

Please email course staff at cs145@cs.stanford.edu for further assistance with your OTC account. To have your password reset, just send your account login (the cs145_user one) with your request. You should never send a password, and staff should never ask for it. (Keep the last line in mind; it is often true of good security systems in the real world.)

Homework 3 Questions and Answers

  1. Why are some constants in XQuery surrounded by apostrophes, some not?
    XQuery requires either apostrophes or quotation marks around literal strings (your choice, for each string), and forbids apostrophes or quotation marks for literal numbers (integers and floating point).
    (Reference: XQuery working draft 15 Nov 2002, Section 3.1.1 or A.1.1.)
  2. Does an XQuery expression need to be surrounded by braces { } in a return clause?
    (Reference: XQuery working draft 15 Nov 2002, Sections A.2, 3.7.1.)
  3. What does it mean for an XPath expression to have a contiguous sequence of [condition a][condition b] = Any point where a condition in brackets is permitted, multiple conditions, each in brackets, are permitted one after another. Where multiple conditions appear, all of them apply.
  4. What do parent:: and self:: mean in XPath (and XQuery)?
    Relative to a node, parent:: means to consider the node one step toward the root of the tree, rather than the default of considering all children nodes. self:: means to consider the same node, rather than the default of considering all the children nodes. So, for example, where Element or child::Element means to select any child elements named Element, parent::Element means to select any element named Element one step "up" (toward the root of the tree), and self::Element means to select any node itself, if it is named Element. The designation before the double colon is called the axis, as mentioned in class.
  5. What does node() test in XPath (and XQuery)? The function node() selects (matches) any node. For example, where self::Element selects a node itself only if it is named Element, self::node() selects itself as long as it is a node.

CS145 Web pages - email the staff