Xquery Tutorial
35 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
35 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

Xquery TutorialCraig KnoblockUniversity of Southern California„„„„„„„„„„ReferencesXQuery 1.0: An XML Query Language www.w3.org/TR/xquery/XML Query Use Cases www.w3.org/TR/xmlquery-use-casesXquery Interpreter:http://prometheus2.isi.edu:9001/xquery.htmlAdvice: Case mattersWrite your queries incrementally!It is hard to debug entire queriesExample XML Document: bib.xml TCP/IP Illustrated StevensW. Addison-Wesley 65.95 Advanced Programming in the Unix environment 65.95 Example XML Document: bib.xml Data on the Web AbiteboulSergeBunemanPeterSuciuDan Morgan Kaufmann Publishers 39.95 The Economics of Technology and Content for Digital TV GerbargDarcy CITI Kluwer Academic Publishers 129.95 OOOOOODoes the world need a new query language?Most of the world's business data is stored in relational databases.The relational language SQL is mature and well-established. Can ...

Informations

Publié par
Nombre de lectures 21
Langue English

Extrait

Xquery
Tutorial
Craig Knoblock
University of Southern California
„ „ „
References
XQuery 1.0: An XML Query Language „ro/gRTx/wwww..3query/ XML Query Use Cases „www.w3.org/TR/xmlquery-use-cases Xquery Interpreter: „uexq.hryltmuehtemorp//:ptth1/00:9du.esi.is2 „Advice: „Case matters „Write your queries incrementally! „It is hard to debug entire queries
Example XML Document: bib.xml
<bib> <book year="1994"> <title>TCP/IP Illustrated</title> <author><last>Stevens</last><first>W.</first></author> <publisher>Addison-Wesley</publisher> <price> 65.95</price> </book> <book year="1992"> <title>Advanced Programming in the Unix environment</title> <author><last>Stevens</last><first>W.</first></author> <publisher>Addison-Wesley</publisher> <price>65.95</price> </book>
utho></airstr</fsa>t>rl<tuoh>ra<ir<ft>as/lu<ciSu/<>tsrif/<naD>ts</first>st>Serge<>uahtro/<uahtroemun</anla><>Bst>tsretePtsalif<>9.<5 >93ec >p/irok> </bok ye<boo9991"=raltit< >"Ece The>s icomonuahtro >p<builhser>Morgan KaufmaP nnilburehsp/<sliubersh<p> cerisrif/<ycraD>tsri<ft>as/lg<arrbGetaoiifil/<faICITion>liataffit> <of tiD roC dnetnogolany  Tofhnec >l<sa>t< detiro</title>gital TVoo/b <e>ib/b <k>.921>ecicirp/<59 >
Example XML Document: bib.xml
shli>KerwelucarA< >nide/>rotbup<</publisher> <predim cuPlbsiehsr"> <2000ar="k yeb<ooast><fireboul</lsa>tbAtituoh>rl<leit<a> Wee /tb<o atht nltitaD>e
Does the world need a new query language?
The Web
Structured Databases
O
O
O
O
Most of the world's business data is stored in relational databases.
The relational language SQL is mature and well-established.
Can SQL be adapted to query XML data? OLeverage existing software OLeverage existing user skills
How is XML data different from relational data?
5
O
O
O
O
O
Nesting
Relational data is "flat"rows and columns
XML data is nestedand its depth may be irregular and unpredictable
Relations can represent hierarchic data by foreign keys or by structured datatypes
In XML it is natural to search for objects at unknown levels of the hierarchy: "Find all the red things."
XPath is a compact and convenient notation for this type of query: //*[@color = "Red"]
6
O
O
Metadata
Relational data is uniform and repetitive
OAll bank accounts are similar in structure
OMetadata can be factored out to a system catalog
XML data is highly variable
OEvery web page is different
OEach XML object needs to be self-describing
OMetadata is distributed throughout the document
OQueries may access metadata as well as data: "Find elements whose name is the same as their content"
//*[name(.) = string(.)]
7
O
O
O
Heterogeneous Sequences
Relational queries return uniform sets of rows
The results of an XML query may have mixed types and complex structures.
O"Red things": a flag, a cherry, a stopsign, . . .
OElements can be mixed with atomic values ("mixed data")
XML queries need to be able to perform structural transformations OExample: invert a hierarchy
8
Ordering
OThe rows of a relation are unordered OAny desired output ordering must be derived from values
OThe elements in an XML document are ordered
OImplications for query:
OPreserve input order in query results OSpecify an output ordering at multiple levels O"Find the fifth step" O"Find all the tools used before the hammer"
<book>
<project>
<name>
<step>
<tool>
9
O
O
Missing Information
Relational data is "dense" Orow has a value in every columnEvery OA "null" value is needed for missing or inapplicable data
XML data can be "sparse" OMissing or inapplicable elements can be "empty" or "not there" OThis gives XML a degree of freedom not present in relational databases
01
Xquery Overview
„
„
Xquery is an expression language
„Every statement evaluates to some result „:= 5 let $y := 6 return 10*$x+$ylet $x „Evaluates to 56
Primitive types
„Number, boolean, strings, dates, times, durations, and XML types
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents