Debian Codegraph @

whelp/AQL/future.shtml

raw
1 <HTML>
2
3 <HEAD>
4 <TITLE>AQL - Future developments</TITLE>
5 <LINK REL="stylesheet" TYPE="text/css" HREF="./aql.css" TITLE="Style sheet for AQL docs">
6 </HEAD>
7 <BODY>
8
9
10 <H2>AQL - Future developments</H2>
11
12
13 <UL>
14 <LI><FONT SIZE=+2>Optimisation techniques</FONT>
15 <P>
16 <OL>
17 <LI> <FONT SIZE=+1>uncorrelated subqueries</FONT>
18 <P>list all movie titles with an above-average rating</P>
19 <CODE><EM>select</EM> m->Title <EM>from </EM>m <EM>in class</EM> Movie <EM>where</EM> m->Rating > <EM>avg</EM>(<EM>select</EM> m->Rating <EM>from</EM> m <EM>in class</EM> Movie)</CODE>
20
21 <P>The subquery is inside the <TT><EM>avg</EM>()</TT> expression is
22 clearly unrelated to the outer main-query, as it generates
23 just one value independent of the outer query. In the current
24 logic of the language it will be evaluated over and over again
25 for every movie that has a <TT>->Rating</TT> value.</P>
26
27 <P>Currently this query has to be optimised by hand into the form:</P>
28 <CODE>$x := <EM>avg</EM>(<EM>select</EM> m->Rating <EM>from</EM> m <EM>in class</EM> Movie); <BR>
29 <EM>select</EM> m-&gt;Title <EM>from</EM> m <EM>in class</EM> Movie <EM>where</EM> m-&gt;Rating &gt; $x</CODE>
30
31 <P><HR WIDTH=50%></P>
32 <LI> <FONT SIZE=+1>more semantic-sensitivity</FONT>
33 <P>These two queries have the same result :-</P>
34
35 <CODE><EM>select</EM> p, m<BR>
36 <EM>from</EM> p <EM>in class</EM> person, m <EM>in class</EM> movie<BR>
37 <EM>where</EM> p->Stars_In = m</BR>
38 <BR>
39 <EM>select</EM> p, p->Stars_in<BR>
40 <EM>from</EM> p <EM>in class</EM> person<BR>
41 </CODE>
42 <P>but the first one would take much longer -
43 the query loops over a cartesian product of both classes (Person and Movie),
44 and then then cuts down the result to the tuples for which the <U>where-clause</U> matches.</P>
45
46 </OL>
47
48 <P><HR></P>
49
50 <LI><FONT SIZE=+2>Language extensions</FONT>
51 <P>
52 <OL>
53 <LI> <FONT SIZE=+1>more built-in methods</FONT>
54 <P>More built-in string method like:-</P>
55
56 <P><CODE><EM>select</EM> m <EM>from</EM> m <EM>in class</EM> map <EM>where</EM> m.<EM>substr</EM>(1,3) = "Chr"</CODE></P>
57
58 <P>Other string operators could solve problems like the extraction of the
59 first/last name from the <TT>author->Full_name</TT> strings, etc..</P>
60
61 <P><HR WIDTH=50%></P>
62 <LI> <FONT SIZE=+1>definition of methods</FONT>
63
64 <P>methods are defined upon the default locator, and can later be used on any locator</P>
65
66 <P><CODE>#size := [2]-[1] <EM>where</EM> [2] > [1] + 30000;<BR>
67 <EM>select</EM> x, x.size<BR>
68 <EM>from object</EM>("Sequence","AH6")->Subsequence <EM>as</EM> x<BR>
69 <EM>order by</EM> x.size</CODE></P>
70
71 <P>replaces</P>
72
73 <P><CODE><EM>select</EM> s, size::s[2]-s[1] <BR>
74 <EM>from object</EM>("sequence","LINK_AH10")->subsequence <EM>as</EM> s<BR>
75 <EM>where</EM> s[2] > s[1] + 30000 <BR>
76 <EM>order by</EM> :size</CODE></P>
77
78 <P>It is questionable, whether such functionality, shouldn't be provided by the
79 underlying database, i.e. the sequence model had a <I>calculated</I> field
80 that is updated when any of the fields that it is based on are updated.
81 This would require the implementation of <B>Constraints</B> and <B>Triggers</B>
82 in ACeDB.</P>
83
84
85 <P><HR WIDTH=50%></P>
86
87 <LI> <FONT SIZE=+1>Sorting by expression values</FONT>
88 <P>Currently one can only sort by values that are evaluated as
89 select-fields and included in the results table. In some cases
90 it would be nice to sort by People's age, for instance, but not
91 actually report it.</P>
92
93 <P>It would be very hard to do in one go, as one can only
94 sort tables once their completely filled in, but not as they
95 are made. One approach is transform queries like this</P>
96
97 <P><CODE><EM>select</EM> p <EM>from</EM> p <EM>in class</EM> person <EM>order by yeardiff</EM>(p->date_of_birth,<EM>today</EM>)</CODE></P>
98
99 <P>into</P>
100
101 <P><CODE>@tmp := <EM>select</EM> p, <EM>yeardiff</EM>(<EM>today</EM>,p->date_of_birth) <BR>
102 <EM>from</EM> p <EM>in class</EM> person <EM>order by</EM> :2;<BR>
103 <EM>select</EM> a:1 <EM>from</EM> a <EM>in</EM> @tmp</CODE></P>
104
105
106
107
108 <P><HR WIDTH=50%></P>
109 <LI> <FONT SIZE=+1>A data manipulation language (DML)</FONT>
110 <P>It is desirable to be able to use AQL to update the database, and add new data by AQL commands.
111 It'd be nice if that could be close to the way SQL and OQL do additions and updates.</P>
112
113
114
115
116 <P><HR WIDTH=50%></P>
117 <LI> <FONT SIZE=+1>A data definition language (DDL)</FONT>
118 <P>A well-defined format for database creation, schema-definition would take the
119 pain out of writing and verifying the 'models.wrm' file by hand.</P>
120
121 </OL>
122
123 </UL>
124
125
126 <HR>
127 <ADDRESS><A HREF="mailto:[email protected]">[email protected]</A></ADDRESS>
128
129 </BODY>
130 </HTML>