160 likes | 307 Views
WebDB Workshop on Web and Data Bases, Madison 2002. The Query Language TQL. Speaker: Giovanni Conforti Joint work with: G. Ghelli, A. Albano, D. Colazzo, P. Manghi, and C. Sartiani Università di Pisa. What is TQL?. Yet another semi-structured data query language
E N D
WebDB Workshop on Web and Data Bases, Madison 2002 The Query Language TQL Speaker: Giovanni Conforti Joint work with: G. Ghelli, A. Albano, D. Colazzo, P. Manghi, and C. Sartiani Università di Pisa
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 2002 Giovanni Conforti
Data source Matching structure and filtering Result construction The simplest query from $Bib |= .bib[.book[.year[1991] And .title[$t]]] select title[$t] WebDB Workshop on Web and Data Bases, Madison 2002 Giovanni Conforti
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 2002 Giovanni Conforti
$Bib = Bib[ Book[title[DB]|…] | Book[title[AI]|…] | … ] The data model Nested forests (multisets) of unordered labelled trees WebDB Workshop on Web and Data Bases, Madison 2002 Giovanni Conforti
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 2002 Giovanni Conforti
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 2002 Giovanni Conforti
TQL binding and matchingexamples In all these cases the variable$ais 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 2002 Giovanni Conforti
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 2002 Giovanni Conforti
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 2002 Giovanni Conforti
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 2002 Giovanni Conforti
Expressing tree properties with formulas WebDB Workshop on Web and Data Bases, Madison 2002 Giovanni Conforti
Expressing types with formulas WebDB Workshop on Web and Data Bases, Madison 2002 Giovanni Conforti
from $Bib |= bib[ !book.$t[T] And foreach $X. Not (.book.$t[$X] | .book.$t[$X])] Select key[$t] From checking to extraction from $Bib |= bib[ !book.title[T] And foreach $X. Not (.book.title[$X] | .book.title[$X])] Select title_is_key WebDB Workshop on Web and Data Bases, Madison 2002 Giovanni Conforti
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) • 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 2002 Giovanni Conforti