XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath...

21
XML Databases by Sebastian Graf

Transcript of XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath...

Page 1: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XML Databases

by Sebastian Graf

Page 2: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

Table of Contents

XML Database OverviewXML Database ExampleXPathXML-QLXQueryStoring of XML DatabasesRelational DB vs. XMLXML based Systems

Page 3: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XML Database Overview

XML DBTree structureThink in nodes & axes

Navigation in Tree XPath

Page 4: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XML Database Example<europe>

<country car_code = D memberships = org-eu org-nato …>

<name>Germany</name>

<capital>Berlin</capital>

<poulation> 82 440 134</population>

<country code>de</country code>

<bundesland>

<name>NRW</name>

<capital>Düsseldorf</captial>

<population>18 052 000 </population>

</bundesland>

</country>

</europe>

Page 5: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XPath

Describes how to process XML items logical path to a node (location path)

Provides abstraction for XML languagesXSLTXPointerXQuery

Page 6: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XPath

/europe/country/name

Selects all namesWith predecessor „country“

With predecessor „europe“

Page 7: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XPath examples

/europe/country[population > 50 000 000]

All countries with population > 50 000 000

/europe/country/@car_code

All car_codes of Europe

/europe/country[name = Germany]//capital

All captials in Germany

Page 8: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XPath Conclusion

XPath offers basics navigation and selection features

However it is no complete XML Query LanguageNo joins possible

Page 9: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

Table of Contents

XML Database OverviewXML Database ExampleXPathXML-QLXQueryStoring of XML DatabasesRelational DB vs. XMLXML based Systems

Page 10: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XML-QL

Early proposal for XML Query languageStructure:

<Selection part> <construction part>WHERE #### IN #### CONSTRUCT ####

Result : XML Document

Page 11: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XML-QL Example

WHERE <country car_code=$id><name>$name</>

</>IN “…/europe.xml“CONSTRUCT <country car_code=$id name=$name</>

<result><country car_code=“D” name=“Germany”></><country car_code=“F” name=“France”></>…..

</result>

Page 12: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XQuery

XQuery should extend functionality of XML-QL

Design was related to SQLXQueries are of the form :

FOR ### LET ### WHERE ### RETURN ###

FLWR or FlowerAlso possible:

FOR-IN (FLWR) WHERE … (FLWR) … RETURN … (FLWR)…

Page 13: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XQuery example

Task : find all countires, that have a population > 1 000 000 and have at least 10 cities

FOR $c IN document(„europe.xml“) // countryLET $cities := $c // cityWHERE $c/@population > 1 000 000

AND count($cities) > 10RETURN <bigcountry population = {$c/@population}>

<name>{$c/@name}</name>{$cities}

</bigcountry>

Page 14: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XQuery Join example

Task : find all pairs of countires and cities, that have the same name

FOR $country IN //country, $city IN //city

WHERE $country/name/text() = $city/name/text()

RETURN <pair name={$country/name/text()}

country={$country/@car_code}

city={$city/@country}>

Page 15: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XQuery – what is missing?

No data manipulation in version 1.0Raw Data has to be accessed for data

manipulation

Planned for later versions: Delete Rename Insert Replace

Page 16: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

Table of Contents

XML Database OverviewXML Database ExampleXPathXML-QLXQueryStoring of XML DatabasesRelational DB vs. XMLXML based Systems

Page 17: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

Storing of XML Databases

First Approach : one CLOBWhole Database stored as valueVery easy to implementSQL statements cannot be used for query

Second Approach : transformationTransformation to RelationsSQL statements can be usedHigh transformation effort

Page 18: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

Relational DB vs. XML

The SilkRouteAutomatic transformation : relations XMLPredefined DTD

XperantoMapping of relational Database to XMLAdds XML functionality to DB2

Page 19: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

XML based Systems (B2B)

Software AGTamino

XML platform Storing Development Integreation

eXcelon Query interface for XPath

Page 20: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

More about XML databases

Web & Datenbanken

dpunkt.verlag

by Erhard Rahm & Gottfried Vossen

ISBN : 3-89864-189-9

BA Library : INF G 5100.62

Page 21: XML Databases by Sebastian Graf. Table of Contents XML Database Overview XML Database Example XPath XML-QL XQuery Storing of XML Databases Relational.

THE END

Thanks for your attention