Databases Reference
In-Depth Information
XQuery can return any tree-structure data including tables, graphs, or entire web
pages. This feature eliminates the need for a middle-tier, table-to- HTML translation
layer. Avoiding a middle-tier translation, which includes a separate programming lan-
guage and another data type translation, makes the software development process
simpler and more accessible to nonprogrammers. The elimination of the middle-tier,
relational-to-object-to- HTML translation is one of the core simplification patterns that
makes NoSQL systems more agile and allows faster development of web applications.
O NE QUERY LANGUAGE OR MANY ?
There are many trade-offs to consider when selecting a query language for your data-
base. Small template languages are easy to create and easy to learn, but can be diffi-
cult to extend. Other languages are designed to be extensible with hundreds of
extension functions. Of the many new query languages created over the last dozen
years, XQuery stands out as the most ambitious. Defined by the W3C over a six-year
period using query experts from many domains, its goal was to create a single lan-
guage that can query a broad spectrum of data structures. Where SQL is perfect for
working with tabular data, and languages like XSLT are ideal for transforming docu-
ments, XQuery alone has become the central unification language for querying
diverse types of data in a single language. XQuery also attempts to combine the best
features of modern functional programming languages to prevent side effects and
promote caching (see chapter 10 for further details). Some of the use cases that drove
the specifications of XQuery include these:
Queries on hierarchical data —Generating a table of contents on a document with
nested sections and subsections.
Queries on sequences —Queries based on a sequence of items. For example, in a
calendar what events happen between two other events?
Queries on relational data —Queries similar to SQL where joins are used to merge
data from multiple tables that share common keys.
Queries on documents —Finding titles, paragraphs, or other markup within the
chapter of a topic.
Queries on strings —Scanning news feeds and merging data from press releases
and stock data.
Queries on mixed vocabularies XML data that merges information from auctions,
product descriptions, and product reviews.
Recursive parts explosion —How a recursive query can be used to construct a hier-
archical document of arbitrary depth from flat structures.
Queries with strongly typed data —Using type information in an XML schema to
transform a document.
Now that we've discussed the steps used to import XML and how to use XPath and
XQuery to transform XML data from one form into another, we'll review how to run
updates on XML data and search XML documents that contain full text (structures
that contain natural-language text, for example, English language).
Search WWH ::




Custom Search