Information Technology Reference
In-Depth Information
With respect to our example with question q 1 and its SELECT clauses shown
in Figure 3, the set of FROM clauses is:
F = {state,border,state join border onstate.state name = border info.border, ...} .
Note that there are no weights associated with FROM clauses because it is
not possible to backtrack how many stems made each table appear in
F
.
4 Generating Queries
In the previous section we saw how to create building blocks for queries starting
from a question q . These elements should be paired together in a smart way
to generate the set of queries that possibly answer q . This pairing is obtained
by creating the Cartesian product between clauses sets from which non-valid,
redundant and meaningless clauses are deleted. We use a weighting scheme to
order the most probable correct candidate queries.
4.1 Clause Cartesian Product
In order to find possible answering queries we generate the set
A
=
{S×F×W}
∪{S×F}
. Given that at least one such query exists there should be one pairing
s, f, w∈A
, such that the execution of SELECT s FROM f [WHERE w ] retrieve
the correct answer. Given that each clause set contains on average up to ten
items, this product can result in a very huge set. Thus, when generating all pair-
ings some preliminary conditions are verified, e.g. tables appearing in SELECT
and WHERE clauses should appear in the FROM clause as well, otherwise the
execution of that query will fail. This avoids generating incorrect queries and
wasting time trying to execute them.
To give a simple example, we illustrate in Figure 4 some generated clauses for
the question q 2 , together with possible pairings. The pairing
s 1 ,f 1 ,w 1
is not
correct: it leads to the MySQL error Unknown table: border info .
4.2 Pruning Useless Queries
Once the set
of all valid pairings is built, we additionally prune some of them
which are not useful. For example, meaningless queries project the same field
compared to a value in the selection (e.g. the pairing
A
s 3 ,f 2 ,w 2
answers the
question “ Which state is New York? ” and is clearly useless).
Fig. 4. Possible pairing between clauses for q 2
 
Search WWH ::




Custom Search