Commit 6a5e91f5 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-07-04 23:57:21 by beppe] Few types and formatting changes

Original author: beppe
Date: 2004-07-04 23:57:21+00:00
parent 3d7e49d1
......@@ -32,11 +32,11 @@ where <code>%%e%%</code> is an expression <code>%%b%%</code> a boolean expressio
The <code>select_from_where</code> contruction is tranlated into:
</p>
<sample><![CDATA[
transform %%e1%% with %%p1%% -->
transform %%e2%% with %%p2%% -->
transform %%e1%% with %%p1%% ->
transform %%e2%% with %%p2%% ->
...
transform %%en%% with %%pn%% -->
if %%c%% then [%%e%%] else []
transform %%en%% with %%pn%% ->
if %%c%% then [%%e%%] else []
]]>
</sample>
......@@ -60,9 +60,8 @@ select x from <_ a=x>_ in e]]>
</box>
<box title="Examples" link="exsel">
<p>
<b> The types </b>
</p>
<section title="Types and data for the examples">
<p> Let us consider the following types representing a Bibliography </p>
<sample><![CDATA[
......@@ -108,7 +107,10 @@ let bib : Biblio =
]
]]>
</sample>
<p> <b>Projections</b> </p>
</section>
<section title="Projections">
<p> All titles in the bibliography bib </p>
<sample><![CDATA[
let titles = [bib]/<paper>_/<title>_
......@@ -181,7 +183,11 @@ val papers : [ <paper>[ Author+ Title Conference File ]* ] = [ <paper>[
Ok.
]]>
</sample>
<p> <b> The same queries with the <code>select_from_where</code> construction </b></p>
</section>
<section title="Select_from_where">
<p>The same queries we wrote above can of course be programmed with the <code>select_from_where</code> construction </p>
<p> All the titles </p>
<sample><![CDATA[
let tquery = select y
......@@ -216,7 +222,14 @@ val withouty : [ <title>[ Char* ]* ] = [ <title>[ 'Semantic subtyping' ]
Ok.
]]>
</sample>
<p> <b> Selections </b> select all titles whose at least one author is "Alain Frisch" or "Veronique Benzaken"</p>
<p>
But the <code>select_from_where</code> expressions are likely to be used for
more complex queries such as the one that selects all titles whose at least one
author is "Alain Frisch" or "Veronique Benzaken"
</p>
<sample><![CDATA[
let sel = select y
from x in [bib]/<paper>_ ,
......@@ -244,12 +257,13 @@ Ok.
<p>Note that the corresponding semantics, as in SQL, is a multiset one.
Thus duplicates are not eliminated. To discard them, one has to use the <code>distinct_values</code> operator.
</p>
</section>
<section title="A pure pattern example">
<p>
<b> A pure pattern example </b></p>
<p>
This example computes the same result as the previous query except that duplicates are eliminated. It is written in a pure pattern form (i.e., without any XPath-like projections)
This example computes the same result as the previous query except that
duplicates are eliminated. It is written in a pure pattern form (i.e., without
any XPath-like projections)
</p>
<sample><![CDATA[
......@@ -275,17 +289,19 @@ Ok.
]]>
</sample>
<p>
This pure pattern form of the query yields (in general) better performance than the same one written in an XQuery-like programming style. However, the query optimiser automatically translates the latter into a pure pattern one
This pure pattern form of the query yields (in general) better performance than
the same one written in an XQuery-like programming style. However, the query
optimiser automatically translates the latter into a pure pattern one
</p>
</section>
<section title="Joins">
<p>
<b> Joins </b>
TO BE DONE
</p>
</section>
<p>
<b>A strange query: Formatted table generation</b>
</p>
<section title="An unorthodox query: Formatted table generation">
<p>
The following program generates a 10x10 multiplication table:
</p>
......@@ -303,11 +319,11 @@ let bg ((Int , Int) -> String)
from x in [1 2 3 4 5 6 7 8 9 10];;
]]></sample>
<p>
Result:
The result is the xhtml code that generates the following table:
</p>
<table border="1"><tr><td align="right" style="background:white">1</td><td align="right" style="background:lightblue">2</td><td align="right" style="background:white">3</td><td align="right" style="background:lightblue">4</td><td align="right" style="background:white">5</td><td align="right" style="background:lightblue">6</td><td align="right" style="background:white">7</td><td align="right" style="background:lightblue">8</td><td align="right" style="background:white">9</td><td align="right" style="background:lightblue">10</td></tr><tr><td align="right" style="background:yellow">2</td><td align="right" style="background:lightgreen">4</td><td align="right" style="background:yellow">6</td><td align="right" style="background:lightgreen">8</td><td align="right" style="background:yellow">10</td><td align="right" style="background:lightgreen">12</td><td align="right" style="background:yellow">14</td><td align="right" style="background:lightgreen">16</td><td align="right" style="background:yellow">18</td><td align="right" style="background:lightgreen">20</td></tr><tr><td align="right" style="background:white">3</td><td align="right" style="background:lightblue">6</td><td align="right" style="background:white">9</td><td align="right" style="background:lightblue">12</td><td align="right" style="background:white">15</td><td align="right" style="background:lightblue">18</td><td align="right" style="background:white">21</td><td align="right" style="background:lightblue">24</td><td align="right" style="background:white">27</td><td align="right" style="background:lightblue">30</td></tr><tr><td align="right" style="background:yellow">4</td><td align="right" style="background:lightgreen">8</td><td align="right" style="background:yellow">12</td><td align="right" style="background:lightgreen">16</td><td align="right" style="background:yellow">20</td><td align="right" style="background:lightgreen">24</td><td align="right" style="background:yellow">28</td><td align="right" style="background:lightgreen">32</td><td align="right" style="background:yellow">36</td><td align="right" style="background:lightgreen">40</td></tr><tr><td align="right" style="background:white">5</td><td align="right" style="background:lightblue">10</td><td align="right" style="background:white">15</td><td align="right" style="background:lightblue">20</td><td align="right" style="background:white">25</td><td align="right" style="background:lightblue">30</td><td align="right" style="background:white">35</td><td align="right" style="background:lightblue">40</td><td align="right" style="background:white">45</td><td align="right" style="background:lightblue">50</td></tr><tr><td align="right" style="background:yellow">6</td><td align="right" style="background:lightgreen">12</td><td align="right" style="background:yellow">18</td><td align="right" style="background:lightgreen">24</td><td align="right" style="background:yellow">30</td><td align="right" style="background:lightgreen">36</td><td align="right" style="background:yellow">42</td><td align="right" style="background:lightgreen">48</td><td align="right" style="background:yellow">54</td><td align="right" style="background:lightgreen">60</td></tr><tr><td align="right" style="background:white">7</td><td align="right" style="background:lightblue">14</td><td align="right" style="background:white">21</td><td align="right" style="background:lightblue">28</td><td align="right" style="background:white">35</td><td align="right" style="background:lightblue">42</td><td align="right" style="background:white">49</td><td align="right" style="background:lightblue">56</td><td align="right" style="background:white">63</td><td align="right" style="background:lightblue">70</td></tr><tr><td align="right" style="background:yellow">8</td><td align="right" style="background:lightgreen">16</td><td align="right" style="background:yellow">24</td><td align="right" style="background:lightgreen">32</td><td align="right" style="background:yellow">40</td><td align="right" style="background:lightgreen">48</td><td align="right" style="background:yellow">56</td><td align="right" style="background:lightgreen">64</td><td align="right" style="background:yellow">72</td><td align="right" style="background:lightgreen">80</td></tr><tr><td align="right" style="background:white">9</td><td align="right" style="background:lightblue">18</td><td align="right" style="background:white">27</td><td align="right" style="background:lightblue">36</td><td align="right" style="background:white">45</td><td align="right" style="background:lightblue">54</td><td align="right" style="background:white">63</td><td align="right" style="background:lightblue">72</td><td align="right" style="background:white">81</td><td align="right" style="background:lightblue">90</td></tr><tr><td align="right" style="background:yellow">10</td><td align="right" style="background:lightgreen">20</td><td align="right" style="background:yellow">30</td><td align="right" style="background:lightgreen">40</td><td align="right" style="background:yellow">50</td><td align="right" style="background:lightgreen">60</td><td align="right" style="background:yellow">70</td><td align="right" style="background:lightgreen">80</td><td align="right" style="background:yellow">90</td><td align="right" style="background:lightgreen">100</td></tr></table>
</section>
</box>
</page>
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