Database Reference
In-Depth Information
Chapter 1
Declarative Query Processing
in Relational Database Systems
A common approach to classify programming languages is around
paradigms
,
broadly defined as fundamental styles of computer programming. A tradi-
tional classification distinguishes between imperative languages (in which we
specify
how
to obtain results) and declarative languages (in which we specify
what
we want without detailing
how
to reach the answer).
∗
In this chapter
we contrast these two approaches and motivate the declarative capabilities
of Structured Query Language (
SQL
), the most prevalent query language in
relational database systems. We then briefly review how
SQL
queries are eval-
uated in modern systems and how, in turn, query processing is influenced by
the availability of database indexes. As a consequence, the set of available
indexes, or the
physical design
of a database, is a very important aspect for
performance tuning. We next motivate the physical database design problem
and note that, unless done automatically, it conflicts with the goal of a declar-
ative language. In fact, understanding which are the right indexes for a given
query (or set of queries) forces us to think about
how
queries would be evalu-
ated. Any effective step toward a solution to the physical design problem not
only would make application development more declarative but also would
decrease the total cost of ownership of database installations.
1.1 An Exercise in Imperative Programming
Suppose that we have two arrays of integers,
R
and
S
, and we need to compute
the number of times that some element in
R
matches some element in
S
,
including duplicates (let us denote this functionality by
countMatches
). The
∗
This distinction has been recently blurred by advances in programming languages. We now have
declarative dialects in imperative languages (e.g., LInQ dialects in the Microsoft .NET framework)
and procedural extensions to declarative languages.
3
Search WWH ::
Custom Search