return to index |
xsdb project page with download links xFeedMe xsdb resources |
<query> <consult href="http://www.ittybittym.com/emp.xsdb"/> <s at="EmpNum">123</s> </query>
An ideal query engine always produces a correct response and produces a complete and normal response whenever it is possible to do so.
When a query engine evaluates a query Q it must produce a response R which is correct in the sense that the interpretation of the transformed response R is either equivalent to or weaker than the query Q. If the response R is strictly weaker than the query Q the response must be returned as another query which is marked weak. For example to indicate that no pertinent information could be derived an engine could reply
<query weak="true"> <anything/> </query>And the above trivial response would be a correct but unsatisfactory response to any possible query.
In the event that the response R is equivalent to the query Q we say the response is complete. A trivial query engine could produce correct responses by always responding to each query Q with the response Q, but this would also be unsatisfactory.
In order to indicate that query responses should be useful we define the normal form for a query response to be a restricted class of disjunction of conjunctions of attribute restrictions, but also allow the extrema and simplified forms as special cases. Intuitively, a response is normal if it corresponds to a simple table of data (with some possible empty entries).
In particular the extrema
<anything/> <nothing/>are normal. Any atomic attribute restriction such as
<s name="FirstName">George</s>is normal. Range restrictions are normal provided they are not equivalent to <nothing/> or to an atomic restriction. Thus
<f at="asking"><gt>0</gt><lt>10</lt></f>is normal but
<f at="asking"><ge>1</ge><le>1</le></f>is not normal because it is equivalent to the atomic assertion
<f at="asking">1</f>Conjunctions of normal attribute restrictions and normal range restrictions are normal provided they contain only one restriction for each named attribute. For example
<and> <id at="ISBN">0-596-00292-0</id> <f at="asking">5.0</f> </and>is normal but
<and> <id at="ISBN">0-596-00292-0</id> <f at="asking">5.0</f> <f at="asking"><gt>0</gt><lt>10</lt></f> </and>is not normal because it restricts the "asking" attribute twice.
Finally disjunctions of normal conjunctions are normal provided none of the conjunctions is equivalent to one of the others or weaker than one of the others. For example.
<or xmlns="http://xsdb.sourceforge.net"> <and> <id at="ISBN">0-596-00132-0</id> <s at="Title">Learning Perl</id> <f at="asking">2.0</f> <s at="email">ken@smegu.edu</s> <s at="currency">US Dollars</s> </and> <and> <id at="ISBN">0-596-00132-0</id> <s at="Title">Learning Perl</id> <f at="asking">12.0</f> <s at="email">wilma@smegu.edu</s> <s at="currency">US Dollars</s> </and> </or>is normal but
<or xmlns="http://xsdb.sourceforge.net"> <and> <id at="ISBN">0-596-00132-0</id> <s at="Title">Learning Perl</id> <f at="asking">2.0</f> <s at="email">ken@smegu.edu</s> <s at="currency">US Dollars</s> </and> <and> <id at="ISBN">0-596-00132-0</id> <s at="Title">Learning Perl</id> <f at="asking">12.0</f> <s at="email">wilma@smegu.edu</s> <s at="currency">US Dollars</s> </and> <and> <id at="ISBN">0-596-00132-0</id> <s at="Title">Learning Perl</id> </and> </or>is not normal because the last conjunction is weaker than the other two.
A query engine should strive to produce an ideal response -- a normal response that is complete (and correct). Failing that a query engine should strive to generate the strongest possible normal response which is correct. Note that even a perfectly implemented query engine working under ideal conditions will not always be able to generate a complete normal response to every query because not all queries are equivalent to a normal response. For example if we consider the query
<query xmlns="http://xsdb.sourceforge.net"> <!-- tell me about presidents who don't lie frequently --> <consult href="http://prez.sih.com/databases/presidents/index.xsdb"/> <except> <id at="lies">frequently</id> </except> </query>If the target database does not specify the value of the "lies" attribute there is no way to reduce this query to an equivalent normal response. A correct but weak normal response to this query might list all the presidents in an expression which is marked weak, meaning that the list may be too large.
The response to a query may be ordered by a sort ordering between alternatives (rows) and by an attribute order within conjunctions (columns).
<query atts="name empnum dept salary" sort="salary desc"> <s at="dept">123</s> <consult href="http://www.ittybittym.com/emp.xsdb"/> </query>The above query indicates that the rows should be ordered by descending salary and the attributes of the rows should be ordered with name first followed by empnum, dept, and salary with any remaining attributes omitted. The attribute list is a whitespace delimited sequence of attribute names and the sort order is a comma separated sequence of attribute names optionally followed by "desc" indicating that the attribute should be sorted descending (which is only permitted for numeric attributes).