- 122 Views
- Uploaded on
- Presentation posted in: General

XML Algebra

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

XML Algebra

By

Sailaja P.

KReSIT

IIT Bombay

- Why Algebra
- Gives semantics for a query language
- For efficient query processing

- Few algebrae
- Relational Algebra: For relational data
- Nested Relational Algebra: For nested relational model
- Schema Algebra: For MultiDB interoperability

Sailaja P., KReSIT XML Workshop, IITBombay

- Structure of data
- Deeply structured
- Exact structure not specific

- Recursion
- Structurally recursive

Sailaja P., KReSIT XML Workshop, IITBombay

- Sample Data
<bib>

<book>

<title>Data on the Web</title>

<year>1999</year>

<author>Abiteboul</author>

<author>Buneman</author>

</book>

<book>

<title> XML Query</title>

<year>2000</year>

<author>Mary</author>

</book>

</bib>

Sailaja P., KReSIT XML Workshop, IITBombay

type Bib = bib [ Book{0,*}]

type Book = book [

title [String ],

year [Integer],

author[ String]{1,*}

]

let bib0: Bib = bib [

book [

title [“Data on the Web”], year [1999],

author[“Abiteboul”], author[“Buneman”]

]

book[

title[“XML Query”],year[2000],

author[“Mary”]

]

]

Sailaja P., KReSIT XML Workshop, IITBombay

Eg:project book( children (bib0) )

- Allows a more convenient notation as well (similar to Xpath notation)
- Eg. bib0/book/author
==> author [“Abiteboul”]

author [“Buneman”]

author [“Mary”]

:author [ String ] {0,*}

Sailaja P., KReSIT XML Workshop, IITBombay

Provides for an iterator

- bib0/book/author
- Equivalent :
for b project book(children(bib0)) inproject author(children(b))

Sailaja P., KReSIT XML Workshop, IITBombay

Eg: for b bib0/book in

where value(b/year) <= 2000 then b

==> book [

title [ “Data on the web”],

year [“1999”],

author[“Abiteboul”],

author[“Buneman”]

]

: Book{0,*}

Sailaja P., KReSIT XML Workshop, IITBombay

type Reviews =

reviews [

book [

title [String],

review [ String]

]{0,*}

]

let review0: Reviews =

reviews[

book [ title[“XMLQuery”],

review[“A fine book”]

],

book [ title[“Data on Web”],

review[“This is great”]

]

]

Sailaja P., KReSIT XML Workshop, IITBombay

- Expression
for b bib0/book in

for r review0/book in

where value(b/title) = value(r/title) then

book [ b/title, b/author, r/review]

==> book [

title [“Data on the web”], author[“Abiteboul”],

author[“Buneman”]

review[“A fine book”]

],

Sailaja P., KReSIT XML Workshop, IITBombay

book[

title[“XML Query”],

author[“Mary”],

review[“This is great”]

]

: book[

title[String ],

author[String]{1,*},

review[String]

]{0,*}

Sailaja P., KReSIT XML Workshop, IITBombay

- Index function pairs an integer index with each element in a forest
- Eg: index(book0/author)
==> pair[fst[1],snd[author[“Abiteboul”]]],

pair[fst[2],snd [author[“Buneman”]]],

pair[fst[3],snd [author[“Suciu”]]] :pair[fst[Integer],snd[author[String]]]{1,*}

Sailaja P., KReSIT XML Workshop, IITBombay

- Has five built-in aggregation
functions: avg,count, max, min and sum

- Eg:
for b bib0/book in

where count(b/author) >= 2 then b/title

==> title[“Data on the web”]

: title{0,*}

Sailaja P., KReSIT XML Workshop, IITBombay

- Structural Recursion
- To define documents with recursive structure, recursive types are used

- Sorting
- sort(pairs)

- Grouping
- Group(pairs)

Sailaja P., KReSIT XML Workshop, IITBombay

- Important contributions
- Operators are orthogonal, strongly typed
- Operators do obey laws of equivalence and optimization

- Issues to be resolved
- Querying over global order is not defined
- Equality and relational operators on element and scalar types are not defined.

Sailaja P., KReSIT XML Workshop, IITBombay

- http://www.cs.bell-labs.com/~wadler/topics/xml.html#algebra
- For an implementation of the algebra:
http://www-db.research.bell-labs.com/user/simeon/xa.html

- http://www.w3.org/TR/query-datamodel
- This presentation will be put up:
- http://www.it.iitb.ernet.in/~sailu/Algebra.html

Sailaja P., KReSIT XML Workshop, IITBombay