Commit 76f24605 authored by Pietro Abate's avatar Pietro Abate

[r2004-07-05 15:27:11 by vbenzake] Empty log message

Original author: vbenzake
Date: 2004-07-05 15:27:11+00:00
parent 84693017
......@@ -295,13 +295,83 @@ optimiser automatically translates the latter into a pure pattern one
</p>
</section>
<section title="Joins">
<p>
TO BE DONE
This example is the exact transcription of query Q5 of XQuery use cases.
We first give the corresponding CDuce types. We leave the user in charge of creating the corresponding relevant values.
</p>
<sample><![CDATA[
type Bib = <bib>[Book*]
type Book = <book year=String>[Title (Author+ | Editor+ ) Publisher Price]
type Author = <author>[Last First]
type Editor = <editor>[Last First Affiliation]
type Title = <title>[PCDATA]
type Last = <last>[PCDATA]
type First = <first>[PCDATA]
type Affiliation = <affiliation>[PCDATA]
type Publisher = <publisher>[PCDATA]
type Price = <price>[PCDATA]
]]>
</sample>
<p>
The queries are expressed first in an XQuery-like style, then in a pure pattern style: the first pattern-based query is the one produced by the automatic translation from the first one. The last query correponds to a pattern aware programmer's version.
</p>
<p>
XQuery style
</p>
<sample><![CDATA[
<books-with-prices>
select <book-with-price>[t1
<price-amazon>([p2]/_) <price-bn>([p1]/_)]
from b in [biblio]/Book ,
t1 in [b]/Title,
e in [amazon]/Entry,
t2 in [e]/Title,
p2 in [e]/Price,
p1 in [b]/Price
where t1=t2
]]>
</sample>
<p> Automatic translation of the previous query into a pure pattern (thus more efficient) one </p>
<sample><![CDATA[
<books-with-prices>
select <book-with-price>[t1 <price-amazon>x11 <price-bn>x10 ]
from <_>[(x3::Book|_)*] in [biblio],
<_>[(x9::Price|x5::Title|_)*] in x3,
t1 in x5,
<_>[(x6::Entry|_)*] in [amazon],
<_>[(x7::Title|x8::Price|_)*] in x6,
t2 in x7,
<_>[(x10::_)*] in x9,
<_>[(x11::_)*] in x8
where t1=t2
]]>
</sample>
<p>
Pattern aware programmer's version of the same query (hence hand optimised).
This version of the query is very efficient. Be aware of patterns.
</p>
<sample><![CDATA[
<books-with-prices>
select <book-with-price>[t2 <price-amazon>p2 <price-bn>p1]
from <bib>[b::Book*] in [biblio],
<book>[t1&Title _* <price>p1] in b,
<reviews>[e::Entry*] in [amazon],
<entry>[t2&Title <price>p2 ;_] in e
where t1=t2
]]>
</sample>
</section>
<section title="An unorthodox query: Formatted table generation">
<p>
The following program generates a 10x10 multiplication table:
</p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment