Download presentation
Presentation is loading. Please wait.
1
Managing XML and Semistructured Data Lecture 8: Query Languages - XML-QL Prof. Dan Suciu Spring 2001
2
In this lecture XML-QL features patterns, constructors, nested queries skolem functions Constructing trees in XML-QL XML-QL compared with XQuery Resources XML-QL: A Query Language for XML by Deutsch, Fernandez, Florescu, Levy, Suciu, in WWW8.XML-QL: A Query Language for XML Data on the Web Abiteboul, Buneman, Suciu : section 5.1
3
XML-QL First declarative language for XML How to obtain a query language for XML fast ? –Assume OEM as data model –Use features from UnQL and StruQL Patterns Templates Skolem functions –Design XML-like syntax
4
Patterns in XML-QL WHERE Morgan Kaufmann $A in “www.a.b.c/bib.xml” CONSTRUCT $A WHERE Morgan Kaufmann $A in “www.a.b.c/bib.xml” CONSTRUCT $A Find all authors who published in Morgan Kaufmann: Abbreviation: closes any tag.
5
Patterns in XML-QL where $A in “www.a.b.c/bib.xml” $A Jones in “www.a.b.c/bib.xml” construct $X where $A in “www.a.b.c/bib.xml” $A Jones in “www.a.b.c/bib.xml” construct $X Find all languages in which Jones’ coauthors have published: There is a join here…
6
Constructors in XML-QL where $A in “www.a.b.c/bib.xml” construct $A $L where $A in “www.a.b.c/bib.xml” construct $A $L Result is: Smith English Smith Mandarin Doe English.. Find all authors and the languages in which they published:
7
Nested Queries in XML-QL WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $L WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $L Find all authors and the languages in which they published; group by authors: Note: book.author is a (regular) path expression
8
Smith English Mandarin … Doe English … Result is:
9
Skolem Functions in XML-QL WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A $L WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A $L Same query, with Skolem functions Assumptions: the ID attribute is always id default Skolem function for author is G($A), for lang is H($A, $L) (why ?)
10
Skolem Functions in XML-QL { WHERE $A $T in “www.a.b.c/bib.xml” CONSTRUCT $A $T /* implicit Skolem function H($A, $T) */ } { WHERE $A $T $J in “www.d.e.f/papers.xml” CONSTRUCT $A $T /* implicit Skolem function J($A, $T) */ $J /* implicit Skolem function K($A, $T) */ } { WHERE $A $T in “www.a.b.c/bib.xml” CONSTRUCT $A $T /* implicit Skolem function H($A, $T) */ } { WHERE $A $T $J in “www.d.e.f/papers.xml” CONSTRUCT $A $T /* implicit Skolem function J($A, $T) */ $J /* implicit Skolem function K($A, $T) */ } Object fusion with Skolem functions and block structure - Compile a complete list of authors, from two sources
11
Result: (some have only books, Others only papers, Others have both) Smith Book1 Book2 Jones Book3 paper1 journal1 Mark paper2 journal3 …
12
Skolem Functions in XML-QL WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A $L WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A $L “Wrong” query number 1: What is “wrong” here ?
13
Skolem Functions in XML-QL WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A $L WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $A $L “Wrong” query number 2: What is “wrong” here ?
14
Skolem Functions in XML-QL { WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $L } { WHERE $C $X in “www.a.b.c/bib.xml” CONSTRUCT $L } { WHERE $A in “www.a.b.c/bib.xml” CONSTRUCT $L } { WHERE $C $X in “www.a.b.c/bib.xml” CONSTRUCT $L } “Wrong” query number 3:
15
Three Rules to Construct Only Trees Rule 1: nested elements must have Skolem functions with arguments such that args1 args2 Rule 2: an element that has an atomic content must have a Skolem function with $X args CONSTRUCT … CONSTRUCT … CONSTRUCT … $X …
16
Contructing trees with Skolem fcns (con’t) Rule 3: if a Skolem function occurs in two different places then the following must hold: –G = H –args1 = args2 –tag1 = tag2 { CONSTRUCT … }
17
XML-QL v.s. XQuery Xquery (=Quilt) v.s. XML-QL + faithful XML data model + Xpath sublanguage + aggregate functions (like in SQL) + some features from XQL -Patterns -Skolem functions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.