Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Query Language TQL Speaker: Giovanni Conforti Joint work with: G. Ghelli, A. Albano, D. Colazzo, P. Manghi, and C. Sartiani Università di Pisa WebDB.

Similar presentations


Presentation on theme: "The Query Language TQL Speaker: Giovanni Conforti Joint work with: G. Ghelli, A. Albano, D. Colazzo, P. Manghi, and C. Sartiani Università di Pisa WebDB."— Presentation transcript:

1 The Query Language TQL Speaker: Giovanni Conforti Joint work with: G. Ghelli, A. Albano, D. Colazzo, P. Manghi, and C. Sartiani Università di Pisa WebDB Workshop on Web and Data Bases, Madison 2002

2 What is TQL? Yet another semi-structured data query language With classic match-filter-construct query structure (obviously) It can be used to query XML files Also capable to express regular path expressions and query on the structure WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

3 The simplest query from $Bib |=.bib[.book[.year[1991] And.title[$t]]] select title[$t] Data source Matching structure and filtering Result construction WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

4 But, what’s the difference? (The Tree Logic) A tree (forest) unordered data model Based on a modal tree logic, a variant of the ambient logic that allows: –Easy “declarative” way to express property of forests (such as constraints and types) –Powerful operators (such as quantification, negation and modal recursion) –Both horizontal and vertical primitive operators –Formal and sharp semantics definition WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

5 The data model Nested forests (multisets) of unordered labelled trees Bib[ Book[title[DB]|…] | Book[title[AI]|…] | … ] $Bib = WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

6 How is this logic used? (A different way to extract data) A tree logic based pattern matching (the binding operation), that allows: –Binding of free variables in formulas –Property checking –Easy generalization from property checking to extraction of pieces of data that satisfy a property –As an example we can infer data structure as a generalization of checking types WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

7 Some TQL primitive operators.L[A] stands for “there is an element labelled l whose content satisfies the subformula A ” In tree logic this operator is an abbreviation for L[A]|T L[A] a tree labelled L whose content satisfies A T stands for true and matches every forest A|A’ vertical splitting of the forest into two subforests satisfying the corresponding formulas WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

8 TQL binding and matching examples Data source Formula title[IDB] | author[Date] | year[1994] author[$a] | Title[IDB] | year[1994] title[IDB] | author[Date] | year[1994] author[$a] | T author[Date]author[$a] | T In all these cases the variable $a is bound to “Date”, but in general we can bound in the same formula different variables to different values WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

9 Another simple example from $Bib |=.bib.book[year[1992] | $EveryThingElse ] select BookOf1992[$EveryThingElse] In this query we show a possible use of the vertical splitting operator Note that we bound a forest to the variable In XQuery this kind of queries need external operators WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

10 Label variables to query structure from $Bib |=.bib.book.$tag.first[Serge] select SergeTag[$tag] Simply finds all tags where the string “Serge” appears inside a element labelled “first” The reconstruction expression put this values one at time inside a SergeTag element WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

11 Logic operators Tree logic also includes classic logical operators: –A and A’, A or A’, not A –foreach $X. A, exists $X. A Label comparison Modal recursion (minimal and maximal fixpoint operators) –Rec $E. A, Maxrec $E. A Derived (regular path expressions) and dual operators WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

12 Expressing tree properties with formulas Is title mandatory? bib[Not.book[Not.title[T]]] Or With path operators.bib!book.title[T] Does title appear twice?.bib.book[.title[T] |.title[T]] Is title a “key” for books? bib[foreach $X. Not (.book.title[$X] |.book.title[$X])] WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

13 Expressing types with formulas Does bib contain only books? bib[foreach $x..$x[T] implies $x=book] A DTD type formula for book A+ = rec $E. A | $E or A book[ year[‘%] | title[‘%] | author[‘%]+ or editor[‘%]+ | (publisher[‘%] or 0) | price[‘%] ] Is the source a binary tree? rec $Bin. %[$Bin] | %[$Bin] or ‘% or 0 WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

14 From checking to extraction from $Bib |= bib[ !book.title[T] And foreach $X. Not (.book.title[$X] |.book.title[$X])] Select title_is_key from $Bib |= bib[ !book.$t[T] And foreach $X. Not (.book.$t[$X] |.book.$t[$X])] Select key[$t] WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti

15 Conclusions TQL is a nice “declarative” query language All queries we have seen and other in the paper are tested on the current implementation Give a look at it (free download at http://tql.di.unipi.it/tql) http://tql.di.unipi.it/tql Its implementation is far from obvious and it is based on a translation into an algebra of table and trees [IFIP TCS 2002] WebDB Workshop on Web and Data Bases, Madison 2002Giovanni Conforti


Download ppt "The Query Language TQL Speaker: Giovanni Conforti Joint work with: G. Ghelli, A. Albano, D. Colazzo, P. Manghi, and C. Sartiani Università di Pisa WebDB."

Similar presentations


Ads by Google