Top Banner
ADT 2010 ADT 2010 XML/XQuery Data Management XML/XQuery Data Management MonetDB/XQuery (1/2) MonetDB/XQuery (1/2) Beyond Chapter 10 of Beyond Chapter 10 of Silberschatz, Korth, Sudarshan Silberschatz, Korth, Sudarshan “Database System Concepts” “Database System Concepts” Stefan Manegold [email protected] http://www.cwi.nl/~manegold/
48

ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

Jan 02, 2016

Download

Documents

Miranda Powell
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

ADT 2010ADT 2010

XML/XQuery Data ManagementXML/XQuery Data Management

MonetDB/XQuery (1/2)MonetDB/XQuery (1/2)

Beyond Chapter 10 ofBeyond Chapter 10 of

Silberschatz, Korth, SudarshanSilberschatz, Korth, Sudarshan

“Database System Concepts”“Database System Concepts”

Stefan [email protected]

http://www.cwi.nl/~manegold/

Page 2: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

2

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

why• Motivation & The Big Picture: XML, DTD, XML Schema, XPath

what• Crash Course XQuery

WHO • XML files Saxon, Galax, GNU Qexo• XML DBMS eXist, BerkeleyDB, MonetDB, X-Hive, Tamino,

Xyleme, ...• XML RDBMS Oracle10g, SQLserver 2005, DB2

how• Under The Hood of MonetDB/XQuery• Some Benchmarks

XML DatabasesXML Databases

Page 3: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

3

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML Data Management SystemsXML Data Management Systems

XML File Processors Used as part of a document processing pipeline Small documents (messages)

XQuery Processor

XML

input

XML

output

Page 4: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

4

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML File ProcessorsXML File Processors Used as part of a document processing pipelineUsed as part of a document processing pipeline Small documents (messages)Small documents (messages)

XML Databases Manage large collections of XML documents Text Keyword Search Support (XML contains text..) Integration with Web Servers/Platforms

web server

application logic

web browser

the internet

XML DBMS

requestHTML

XMLXQuery

XML Data Management SystemsXML Data Management Systems

Page 5: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

5

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML File ProcessorsXML File Processors Used as part of a document processing pipelineUsed as part of a document processing pipeline Small documents (messages)Small documents (messages)

XML Databases Manage large collections of XML documents Text Keyword Search Support (XML contains text..) Integration with Web Servers/Platforms

web server

xslt rendering

web browser

the internet

XML DBMS

requestXHTML

XMLXQuery

=

XML Data Management SystemsXML Data Management Systems

Page 6: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

6

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML File ProcessorsXML File Processors Used as part of a document processing pipelineUsed as part of a document processing pipeline Small documents (messages)Small documents (messages)

XML DatabasesXML Databases Manage large collections of XML documentsManage large collections of XML documents Text Keyword Search Support (XML contains text..)Text Keyword Search Support (XML contains text..) Integration with Web Servers/PlatformsIntegration with Web Servers/Platforms

XML Integration Platforms XML as lingua franca to integrate data XML data: intergrate data sources in XML; real-time access XML messaging: SOA frameworks (SOAP/WSDL,UDDI,BCEL) XQuery/XSLT for querying/transforming XML Integrated in J2EE/.NET application server (JXQ, XLinq)

RDBMS with XML Functionality Easily mix relational and XML, can be very useful for that .ini/properties file Query the XML VARCHAR with SQL/XML ugly but works

web server

application logic

web browser

the internet

RDBMS

request

XMLSQL/XML

xml

HTML

XML Data Management SystemsXML Data Management Systems

Page 7: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

7

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML Data Management SystemsXML Data Management Systems(Google hits)(ranking)

XML File Processors

XML Databases

RDBMS with SQL/XML Functionality

#317KGalax xquery

#241KQexo xquery

#1743KSaxon xquery

#2438KMark Logic xquery

#11440KeXist xquery

#656KTamino xquery

#565KX-Hive xquery

#487KMonetDB xquery

#3142KBerkeleyDB XML xquery

#2225KXindice xquery

#21220KSQLServer xquery

#11470KOracle xquery

Page 8: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

8

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML DatabasesXML DatabasesQueryingHow well is XPath/XQuery implemented?

All Axes? Collations? XMLSchema? Dynamic Typing? Modules? Recursive UDF?UpdatesWhat update dialect is used? (XUpdate / updateX / WebDAV / other)

W3C Update Facility Proposal (since jan 2006!)DB propertiesQuery performance/throughput (benchmarks published?)Update consistency model (fully serializable / snapshot consistency / s.th. less)Replication, Failover, Backup facilities APIsSOAP / WSDL

Call a query from outside <=> Calling out from a queryWeb Support

Cocoon/apache modules (web sessions, low overhead web queries)XML Beans (J2EE served from XMLDB)WebDAV

Language bindingsXQJ =>Java Binding / Xlinq => C# Binding

Page 9: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

9

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML DBMS comparisonXML DBMS comparison

+

+

-

+

-

++

+

fulltext

++++++Mark Logic

+++++++Tamino

+++++++++++X-Hive

+-++++++MonetDB/XQuery

++++++++BerkeleyDB XML

+--+-Apache Xindice

+++-+++eXist

APIsreplicationscalabilityupdatesxquery

Page 10: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

10

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML in a Relational DBMSXML in a Relational DBMS

• Store XML as a BLOB in relational database • index by materializing indexed expressions in separate columns

• Plus: store XML in parsed and validated form

• Minus: proprietary solution (blob is a black box)

• Minus: replicate data for indexing

• Schema-based Shredding

• Map XML Schema / DTD to SQL DDL

• Plus: integrates well with relational data

• Minus:  missing tools, complicated

•  SQL / XML

• Extend SQL with XML data type

• Plus: integrates well with relational data

• Minus: not clear how it integrates with application, odd „marriage“

Page 11: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

11

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

History of SQL / XMLHistory of SQL / XML

• First edition part of SQL:2003• Part 14 of the SQL standard

• Pre-dates XQuery standard!!!

• Limited functionality - storage and publishing

• Second edition• More complete integration of XQuery + XQuery Data Model

• Advanced Query capabilities

• Published in 2006

Page 12: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

12

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

<Phantasy-People>

<row>

<Id>4711</Id>

<Name>Wutz</Name>

</row>

<row>

<Id>911</Id>

<Name>Potter</Name>

</row>

</Phantasy-People>

Potter911

Wutz4711

NameId

Phantasy-People

Publishing Rel. Data as XML (1/2)Publishing Rel. Data as XML (1/2)

Page 13: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

13

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Publishing Rel. Data as XML (2/2)Publishing Rel. Data as XML (2/2)

Page 14: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

14

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Publishing XML as Rel. TablePublishing XML as Rel. Table

('$MyDB//customer'

Page 15: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

15

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XML Type in SQLXML Type in SQL

• A new type (like varchar, date, numeric)

• SQL:2003 - XML type restricted to• XML document or

• XML element or

• Sequence of XML elements

• SQL / XML, 2nd edition• Full support of XQuery Data Model

• XML(SEQUENCE), XML(ANY CONTENT), ...

Page 16: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

16

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Example (SQL:2003)Example (SQL:2003)create table books(title varchar(20),authors XML);

„P. Boncz“MonetDB

<author>D. Chamberlin </author>

<author>D. Florescu</author>

<author>et al.</author>

XQuery 1.0

AuthorsTitle

No schema validation, no typing!

• SQL:2006 => explicit validation with XMLVALIDATE()

Page 17: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

17

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XMLQueryXMLQuery

XMLQuery(

XQuery-expression

PASSING { BY REF | BY VALUE}

(value-expression AS identifier [BY REF | BY VALUE])*

RETURNING { CONTENT|SEQUENCE } { BY REF|BY VALUE}

)

• If PASSING value has no identifier, then that is context node

• BY REF - preserves Id (of an XML type)

• BY VALUE - creates a copy of the data

Page 18: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

18

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

why• Motivation & The Big Picture: XML, DTD, XML Schema, XPath

what• Crash Course XQuery

who• XML files Saxon, Galax, GNU Qexo• XML DBMS eXist, BerkeleyDB, MonetDB, X-Hive, Tamino, Xyleme• XML RDBMS Oracle10g, SQLserver 2005, DB2

HOW • Under The Hood of MonetDB/XQuery• Some Benchmarks

XML DatabasesXML Databases

Page 19: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

19

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XQuery Systems: 2 ApproachesXQuery Systems: 2 Approaches

Native

Tree is basic data structure

• tree-storage manager

• tree-query processing (algebra)

• tree-query optimization

Re-inventing the wheel?

Relational

Leverage RDBMS storage, query processing & optimization

• XML shredded into tables

• XQuery translated into SQL

Let’s use the old rim,

but make a new tyre!

X-Hive TimberDB2BDB-XML

GalaxMicrosoftOracle

MonetDB/XQuery

Page 20: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

20

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

The IdeaThe Idea

Steel

Rim

Aluminium

Tyre

The IdeaThe Idea

Page 21: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

21

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Storing XML in Relations: Schema-Based ApproachStoring XML in Relations: Schema-Based Approach

Page 22: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

22

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Schema-Based Approach: Benefits & DrawbacksSchema-Based Approach: Benefits & Drawbacks

Page 23: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

23

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Peter Boncz, Stefan Manegold (CWI Amsterdam)

Torsten Grust, Jens Teubner, Jan Rittinger (Technische Universität München)

Maurice van Keulen (Technische Universiteit Twente)

MonetDB/XQueryA Fast XQuery Processor Powered by a Relational Engine

[ACM/SIGMOD 2006]

Page 24: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

24

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

MonetDBMonetDB

open-source Mozilla license => download at monetdb-xquery.org

Page 25: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

25

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Pathfinder Project

Torsten Grust, Jens Teubner, Jan Rittinger

Maurice van Keulen

MonetDB/XQueryMonetDB/XQuery

open-source Mozilla license => download at monetdb-xquery.org

Page 26: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

26

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Schema-Oblivious Storage: XPath AcceleratorSchema-Oblivious Storage: XPath Accelerator

Page 27: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

27

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

<a> <b> <c/> </b> <d/> <e> <f> <g/> <h/> </f> <i> <j/> </i> </e> </a>

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Node-based relational encoding of XQuery's data model

Page 28: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

28

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

0<a> 1<b> 2<c/> </b> 3<d/> 4<e> 5<f> 6<g/> 7<h/> </f> 8<i> 9<j/> </i> </e> </a>

Node-based relational encoding of XQuery's data model

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 29: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

29

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

0<a> 1<b> 2<c/>0 </b>1 3<d/>2 4<e> 5<f> 6<g/>3 7<h/>4 </f>5 8<i> 9<j/>6 </i>7 </e>8 </a>9

Node-based relational encoding of XQuery's data model

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 30: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

30

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

0<a> 1<b> 2<c/>0 </b>1 3<d/>2 4<e> 5<f> 6<g/>3 7<h/>4 </f>5 8<i> 9<j/>6 </i>7 </e>8 </a>9

Node-based relational encoding of XQuery's data model

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 31: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

31

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

0<a> 1<b> 2<c/>0 </b>1 3<d/>2 4<e> 5<f> 6<g/>3 7<h/>4 </f>5 8<i> 9<j/>6 </i>7 </e>8 </a>9

Node-based relational encoding of XQuery's data model

① f/following: SELECT * FROM pre_post WHERE pre > f.pre AND post > f.post

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 32: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

32

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

0<a> 1<b> 2<c/>0 </b>1 3<d/>2 4<e> 5<f> 6<g/>3 7<h/>4 </f>5 8<i> 9<j/>6 </i>7 </e>8 </a>9

Node-based relational encoding of XQuery's data model

① f/following: SELECT * FROM pre_post WHERE pre > f.pre AND post > f.post f/descendant: SELECT * FROM pre_post WHERE pre > f.pre AND post < f.post

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 33: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

33

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

0<a> 1<b> 2<c/>0 </b>1 3<d/>2 4<e> 5<f> 6<g/>3 7<h/>4 </f>5 8<i> 9<j/>6 </i>7 </e>8 </a>9

Node-based relational encoding of XQuery's data model

① f/following: SELECT * FROM pre_post WHERE pre > f.pre AND post > f.post f/descendant: SELECT * FROM pre_post WHERE pre > f.pre AND post < f.post f/preceeding: SELECT * FROM pre_post WHERE pre < f.pre AND post < f.post

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 34: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

34

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Node-based relational encoding of XQuery's data model0<a> 1<b> 2<c/>0 </b>1 3<d/>2 4<e> 5<f> 6<g/>3 7<h/>4 </f>5 8<i> 9<j/>6 </i>7 </e>8 </a>9

① f/following: SELECT * FROM pre_post WHERE pre > f.pre AND post > f.post f/descendant: SELECT * FROM pre_post WHERE pre > f.pre AND post < f.post f/preceeding: SELECT * FROM pre_post WHERE pre < f.pre AND post < f.post f/ancester: SELECT * FROM pre_post WHERE pre < f.pre AND post > f.post

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 35: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

35

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Node-based relational encoding of XQuery's data model

① f/following: SELECT * FROM pre_post WHERE pre > f.pre AND post > f.post f/descendant: SELECT * FROM pre_post WHERE pre > f.pre AND post < f.post f/preceeding: SELECT * FROM pre_post WHERE pre < f.pre AND post < f.post f/ancester: SELECT * FROM pre_post WHERE pre < f.pre AND post > f.post

Similar queries for other XPath axes

0<a> 1<b> 2<c/>0 </b>1 3<d/>2 4<e> 5<f> 6<g/>3 7<h/>4 </f>5 8<i> 9<j/>6 </i>7 </e>8 </a>9

XPath Accelerator: XPath Accelerator: pre/postpre/post plane plane

Page 36: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

36

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

pre/postpre/post Table & Table & pre/size/levelpre/size/level Table Table

<a> <b> <c/> </b> <d/> <e> <f> <g/> <h/> </f> <i> <j/> </i> </e> </a>

Pre Posta 0 9b 1 1c 2 0d 3 2e 4 8f 5 5g 6 3h 7 4i 8 7j 9 6

Pre Size Level0 9 01 1 12 0 23 0 14 5 15 2 26 0 37 0 38 1 29 0 3

Post = pre + size - level

Page 37: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

37

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Complete XML Storage SchemaComplete XML Storage Schema

Page 38: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

38

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XPath evaluation (SQL)XPath evaluation (SQL)

Example query: /descendant::open_auction[./bidder]/annotation

SELECT DISTINCT a.pre FROM doc r, doc oa, doc b, doc a WHERE r.pre=0 AND oa.pre > r.pre AND oa.post < r.post AND oa.name = “open_auction” AND oa.kind = “elem” AND b.pre > oa.pre AND b.post < oa.post AND b.level = oa.level + 1 AND b.name = “bidder” AND b.kind < “elem” AND a.pre > oa.pre AND a.post < oa.post AND a.level = oa.level + 1 AND a.name = “annotation” AND a.kind = “elem” ORDER BY a.pre

<- descendant

} child

} child

Page 39: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

39

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

XQuery Systems: 2 ApproachesXQuery Systems: 2 Approaches

Native

Tree is basic data structure

• tree-storage manager

• tree-query processing (algebra)

• tree-query optimization

Re-inventing the wheel?

Relational

Leverage RDBMS storage, query processing & optimization

• XML shredded into tables

• XQuery translated into SQL

Let’s use the old rim,

but make a new tyre!

X-Hive TimberDB2BDB-XML

GalaxMicrosoftOracle

MonetDB/XQuery

Page 40: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

40

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Oracle10g/11g: XQuery SupportOracle10g/11g: XQuery Support

1. XMLDB integrated database engine• SQL / XML standard support

• Optimized queries – rewrite to relational

2. Standalone Java query engine• 100% Java

• Integrated into Oracle App Server -XDS

• Interoperates with XSLT/XPath

First relational database to ship an XQuery implementation !

Page 41: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

41

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Oracle 10g/11g: XQuery database supportOracle 10g/11g: XQuery database support

• Production in Oracle Database 10gr2• Supports XMLQuery and XMLTable construct• Native compilation into SQL /XML structures• Returns XMLType(Content)• Can query over relational, O-R, XMLType data• fn:doc - Maps to XDB Repository on server• SQLPlus provides xquery command to execute XQuery• XSL-T will also get compiled to XQuery

Page 42: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

42

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

Microsoft SQL Server 2005: OverviewMicrosoft SQL Server 2005: Overview

XML ParserXML ParserXMLXML

ValidationValidation

XML datatypeXML datatype

(binary XML)(binary XML)

SchemaSchemaCollectionCollection

XML SchemataXML Schemata

query()query()

modify()modify()Node Node TableTable

PATH PATH Index Index

PROP PROP Index Index

VALUE VALUE Index Index

PRIMARYPRIMARYXML INDEXXML INDEX

query()query()

Page 43: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

43

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

• Create XML index on XML columnCREATE PRIMARY XML INDEX idx_1 ON docs (xDoc)

• Creates secondary indexes on tags, values, paths

• Speeds up queries• Results can be served directly from index

• Entire query is optimized Same award winning cost based optimizer

• Indexes are used as available

Microsoft SQL Server 2005: IndexingMicrosoft SQL Server 2005: Indexing

Page 44: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

44

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

IBM DB2 v9: OverviewIBM DB2 v9: Overview

Page 45: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

45

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

IBM DB2 v9: StorageIBM DB2 v9: Storage

Page 46: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

46

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

IBM DB2 v9: SQL in XQueryIBM DB2 v9: SQL in XQuery

Page 47: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

47

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

IBM DB2 v9: XQuery in SQLIBM DB2 v9: XQuery in SQL

Page 48: ADT 2010 XML/XQuery Data Management MonetDB/XQuery (1/2) Beyond Chapter 10 of Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold.

48

[email protected] XML/XQuery Data Management + MonetDB/XQuery (1/2) ADT 2010

IBM DB2 v9: IndexingIBM DB2 v9: Indexing