Figure 21.2 shows an example of a query tree for the SQL statement of Example 21.1
that uses the relational algebra in its internal representation. We refer to this type of query
tree as a relational algebra tree.
(2) Normalization
The normalization stage of query processing converts the query into a normalized form
that can be more easily manipulated. The predicate (in SQL, the WHERE condition),
which may be arbitrarily complex, can be converted into one of two forms by applying a
few transformation rules (Jarke and Koch, 1984):
n Conjunctive normal form A sequence of conjuncts that are connected with the ∧
(AND) operator. Each conjunct contains one or more terms connected by the ∨ (OR)
operator. For example:
(position = ‘Manager’ ∨ salary > 20000) ∧ branchNo = ‘B003’
A conjunctive selection contains only those tuples that satisfy all conjuncts.
n Disjunctive normal form A sequence of disjuncts that are connected with the ∨ (OR)
operator. Each disjunct contains one or more terms connected by the ∧ (AND) operator.
For example, we could rewrite the above conjunctive normal form as:
(position = ‘Manager’ ∧ branchNo = ‘B003’ ) ∨ (salary > 20000 ∧ branchNo = ‘B003’)
A disjunctive selection contains those tuples formed by the union of all tuples that
satisfy the disjuncts.
(3) Semantic analysis
The objective of semantic analysis is to reject normalized queries that are incorrectly
formulated or contradictory. A query is incorrectly formulated if components do not
contribute to the generation of the result, which may happen if some join specifications
are missing. A query is contradictory if its predicate cannot be satisfied by any tuple. For
example, the predicate (position = ‘Manager’ ∧ position = ‘Assistant’) on the Staff relation is
contradictory, as a member of staff cannot be both a Manager and an Assistant simultaneously.
However, the predicate ((position = ‘Manager’ ∧ position = ‘Assistant’) ∨ salary >
20000) could be simplified to (salary > 20000) by interpreting the contradictory clause