Information Technology Reference
In-Depth Information
The current representation contains approximately 53 grammatical relations
but for our purposes we only use the following: adverbial and adjectival modi-
fier, agent, complement, object, subject, relative clause modifier, prepositional
modifier, and root.
2.2 SQL Queries and Relational Algebra
The general SQL query with which our system can deal has the following form:
SELECT COLUMN FROM TABLE [WHERE CONDITION ]
(1)
The query is interpreted starting from the relation in the FROM clause, select-
ing tuples that satisfy the condition indicated in the WHERE clause (optional)
and then projecting the attribute in the SELECT clause.
In relational algebra, selection and projection are performed by σ and π op-
erators respectively. The meaning of the SQL query above is the same as that
of the relational expression:
π COLUMN ( σ CONDITION ( TABLE ))
(2)
It is worth noting that while relational algebra formally applies to sets of tuples
(i.e. relations), in a DBMS relations are bags so it may contain duplicate tuples
[3]. For our purposes the fact of having duplicates in the result adds nois; this is
why we always delete multiple copies of a tuple by using the keyword DISTINCT
in the COLUMN field. In our QA task we expect that questions can be answered
with a single result set (e.g. we can deal with “ Cities in Texas ”and“ Populations
in Texas ” but not with the combined query “ Cities and their population in
Texas ”). That is, even if in general COLUMN could be a - possibly empty -
list of attributes, in our system it just contains one attribute. We can apply
to this attribute aggregation operators that summarize it by means of SUM,
AVG, MIN, MAX and COUNT, always combined with DISTINCT keyword
(e.g. SELECT COUNT(DISTINCT state.state name) ).
Instead, CONDITION is a logical expression where basic conditions, in the
form e L OP e R ,withOP=
, are combined with AND, OR, NOT
operators. While e L is always in the form table.column , e R could be:
{<,> ,LIKE,IN
}
- numerical value (e.g. city.population > 15000 )or
- string value (e.g. city.state name LIKE "Texas" )or
- nested query (e.g. city.city name IN (SELECT state. capital FROM state)
An example of a complex WHERE condition could be the following:
city.population > 15000 AND city.city name NOT IN (SELECT state.capital
FROM state)) AND NOT city.state name LIKE "Texas" (i.e. “ major non-capital
cities excluding texas ”).
The meaning of TABLE is more straightforward, since it should contain table
name(s) to which the other two clauses refer. This clause could just be a single
relation or a join operation, which selectively pairs tuples of two relations. We
only deal with theta-joins where we take the Cartesian product of two relations
 
Search WWH ::




Custom Search