1 / 29

TAX: A Tree Algebra for XML

TAX: A Tree Algebra for XML. H.V. Jagadish Laks V.S. Lakshmanan Univ. of Michigan Univ. of British Columbia Divesh Srivastava Keith Thompson AT&T Labs – Research Univ. of Michigan Work supported by NSF and NSERC. Overview. Why an algebra for XML?

addo
Download Presentation

TAX: A Tree Algebra for XML

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TAX: A Tree Algebra for XML H.V. Jagadish Laks V.S. Lakshmanan Univ. of Michigan Univ. of British Columbia Divesh Srivastava Keith Thompson AT&T Labs – Research Univ. of Michigan Work supported by NSF and NSERC.

  2. Overview • Why an algebra for XML? • Main challenges • Data model • Patterns & Witnesses • Tree Value Functions • Some Example Operators • Translation Example – XQuery

  3. Overview (contd.) • Main Results • Optimization Examples • Implementation • Summary & Future Work

  4. Why an Algebra (for XML)? (aka Related Work) • Bulk algebra for tree manipulation – efficient implementation of XML queries • Algebra for manipulating trees (has been attempted before) • Feature algebras – linguistics; efficient implementation? • Grammar-based algebra for trees [Tompa+ 87, Gyssens+ 89] • Aqua project [Zdonik+95]

  5. Why XML algebra? [Related work] (contd.) • GraphLog, Hy+ [Consens+90], GOOD [Paradaens+92] – cannot exploit special properties of trees (e.g., support for arbitrary recursion vs. ancestors, order) • SS data – Lorel [Abiteboul+ 96], UnQL [Buneman+ 96]. • XML algebras – [Beech+ 99], [Fernandez+ 00] (mainly type system issues), [Christofidis+ 00] (trees  tuples), [Ludascher+ 00] (nodes, not trees), SAL [Beeri+ 99] (ordered lists of nodes)

  6. Why? (contd.) • be close to relational model, but • direct support for (collections of) trees • express at least RA + aggregation • capture substantial fragment of XQuery • admit efficient implementation and effective query optimization

  7. Main Chellanges • Capture rich variety of manipulations in a simple algebra • Handle heterogeneity in tree collections • structure • “schema” of nodes of the same “type” • Handle order (documents are ordered) • sometimes important (e.g., author list) • sometimes not (e.g., publisher vs. authors)

  8. Data Model • Data tree = rooted ordered tree • Data in node = set of attr-val pairs • Special attribute: pedigree – where did I come from? • “doc id + offset in doc”. • preservedfor (copies of) original nodes thru manipulations. • play important role in grouping, sorting, etc. • null for new nodes. • Collections (of trees) – unordered.

  9. Patterns & Witnesses • first challenge: how do you get at nodes and/or attributes? • our solution: patterns – enable specification of parameters for most operations • only show parts of interest: • Need not know/care about entire structure of trees in collection

  10. Patterns & Witnesses (contd.)  Structural part $1 • Example P1: pc ad $2 $3 $1.tag = book & $2.tag = year & $2.content < 2000 & $3.tag = author pc = direct ad = transitive Condition part Additional parameters possible: e.g., selection/projection lists, grouping, ordering, etc.

  11. Patterns & Witnesses (contd.) • What does a pattern do for you? • generate witnesses against i/p collection • one for each matching of pattern against i/p • conditions must be respected • (sub)structure preserved in o/p • e.g., witness trees for pattern P1 – • one tree for each author of each book published before 2000, showing year & author • book-author link may be transitive in i/p but is necessarily direct in o/p • source trees = trees witnesses “came from”

  12. Tree Value Functions (TVF) • What are they? • Primitive recursive functions on structure of source trees • Where are they used? • grouping, ordering, aggregation, etc. • Here is an example: • f: T  value of author, number of authors, tuple of authors, {author tuple, title}, etc. • Complete example coming up …

  13. Example Database bib book book author year author author title title year Principia Mathematica 1910 560 BC name name deg name deg Ashtadhyayi (First book on Sanskrit Grammar) Sc.D., FRS M.A., FRS Panini first mid last first last Bertrand Russel Alfred North Whitehead

  14. Example Operators – Selection • Input: collection; parameters: pattern, selection list (pattern nodes) • Example • pattern P1 and empty SL: same witness trees as before • pattern P1 with SL = {$1}: whole book subtrees (i.e. retain $1’s descendants) • One-zero/more op in general • Could retain other “relatives” instead (e.g., siblings)

  15. Selection with P1 (empty SL) Whole author subtree included when SL = {$3}. book book book author year author year author year 1910 560 BC 1910

  16. Example operators – Projection • Input: collection; parameters: pattern, projection list • Example • Pattern P1 w/ PL = {$1, $2, $3}: one tree for each book published before 2000, showing year and author(s) • Pattern P1 w/ PL = {$3}: one tree for each author of aforementioned books • `*’ in PL causes descendants to be retained • One-zero/more op (for reasons diff. from select)

  17. Projection: P1 w/ PL = {$1,$2,$3} book book author year author author year 1910 560 BC With $3*, can include whole author subtrees.

  18. Selection vs. Projection • Example FOR $b IN document(“doc.xml”)//book FOR $y IN $b/year[data() < 2000] FOR $a IN $b//author RETURN <book> $y $a </book> versus FOR $b IN document(“doc.xml”)//book[/year/data() < 2000] RETURN <book> $b/year $b/author </book> selection projection

  19. Example operators – grouping • Input: collection; parameters: pattern, grouping TVF, ordering TVF. • Example input: collection of books pattern: f_g(T) = “$4.content” f_o(T) = “$2.content” $1 pc ad $2 $3 pc $1.tag = book & $2.tag = title & $3.tag = author & $4.tag = name $4

  20. Grouping (contd.) • Here is what the o/p looks like: -- books ordered by title in each group tax_group_root … tax_group_basis tax_group_subroot book book author

  21. Other operators • Derived operators – various joins. • Set operations: • When are two data trees the “same”? • Equality (shallow/deep) vs. isomorphism (include pedigree or not?) • Multiset versions of operators • Aggregation, Reordering, Renaming.

  22. Translation Examples – XQuery • FOR $b IN document(“doc.xml)//book[//author@hobby=tennis]RETURN<sportydiveshbook>$b/title IF SOME $a IN $b//author SATISFIES $a/data() = “divesh” THEN $b/author </sportydiveshbook>

  23. XQuery Translation (contd.) • Pre-IF part E: select w/ then project w/ $1 $1.tag=book & $2.tag=author & $2.hobby=tennis SL = $1* $2 $3 $3 PL = $3, $4 PL = $3, $4 $3.tag=book & $4.tag=title $3.tag=book & $4.tag=title $4 $4

  24. XQuery Translation (contd.) • IF part F: select w/ then project w/ $5 $5.tag=book & $6.tag=author & $6.content = divesh SL = $5* $6 $7 PL = $7, $8 $7.tag=book & $8.tag=author $8

  25. XQuery Translation (contd.) • Do a left outerjoin of E with F w/ the condition $3 = $7  • Project w/ • Rename tax_prod_root  sportydiveshbook. tax_prod_root / \ book book . . . | / ... \ title author author $9 $9.tag != book PL = $9

  26. Main Results • Duplicate elimination by value can be expressed in TAX. • The operators in TAX are independent. • TAX is complete for relational algebra w/ aggregation. • TAX can capture the fragment of XQuery FLWR expressions w/o function calls, recursion, w/ all path expressions using only constants, wildcards, and / & //, when no new ancestor-descendant relationships are created.

  27. Optimization Examples • Revisit translation example: • E can be simplified to – project w/ • Similar simplification applies to F • Self-join can sometimes be eliminated • Associativity, commutativity issues $1 $1.tag=book & $2.tag=author & $2.hobby=tennis & $3.tag=title PL= $1,$3 $2 $3

  28. Implementation • TIMBER system at Univ. of Michigan • Find pattern tree matches via • Index scans • Full scans • Twig joins • Joins implemented on streams • Pedigree – implemented as position of element within document • Pedigrees similar to RID at impl. level

  29. Summary & Future Work • TAX – extension of RA for handling heterogeneous collections of ordered labeled trees • Simplicity; few more operators • Recognize selective importance of order and handle elegantly • Bulk algebra for efficient implementation of XML querying • Stay tuned for TIMBER release(s) • Future • Arbitrary restructuring: copy-and-paste • Updates: principled via operators

More Related