Database Reference
In-Depth Information
Chapter 12
Making Query Coding in
SQL Easier by Implementing
the SQL Divide Keyword:
An Experimental Query Rewriter in Java
Eric Draken
University of Calgary, Canada
Shang Gao
University of Calgary, Canada
Reda Alhajj
University of Calgary, Canada & Global University, Beirut, Lebanon
ABSTRACT
Relational Algebra (RA) and structured query language (SQL) are supposed to have a bijective rela-
tionship by having the same expressive power. That is, each operation in SQL can be mapped to one RA
equivalent and vice versa. Actually, this is an essential fact because in commercial database management
systems, every SQL query is translated into equivalent RA expression, which is optimized and executed
to produce the required output. However, RA has an explicit relational division symbol (รท), whereas SQL
does not have a corresponding explicit division keyword. Division is implemented using a combination
of four core operations, namely cross product, difference, selection, and projection. In fact, to imple-
ment relational division in SQL requires convoluted queries with multiple nested select statements and
set operations. Explicit division in relational algebra is possible when the divisor is static; however, a
dynamic divisor forces the coding of the query to follow the explicit expression using the four core op-
erators. On the other hand, SQL does not provide any flexibility for expressing division when the divisor
is static. Thus, the work described in this chapter is intended to provide SQL expression equivalent to
Search WWH ::




Custom Search