<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Chasing Polarized Order Dependencies</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Jaroslaw Szlichta</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Parke Godfrey</string-name>
          <email>godfrey@cse.yorku.ca</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jarek Gryz</string-name>
          <email>jarek@cse.yorku.ca</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>IBM Center for Advanced Studies</institution>
          ,
          <addr-line>Toronto</addr-line>
          ,
          <country country="CA">Canada</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>York University</institution>
          ,
          <addr-line>Toronto</addr-line>
          ,
          <country country="CA">Canada</country>
        </aff>
      </contrib-group>
      <fpage>168</fpage>
      <lpage>179</lpage>
      <abstract>
        <p>Dependencies have played a significant role in database design for many years. They have also been shown to be useful in query optimization. In this paper, we discuss the new type of dependency for polarized lexicographically ordered sets of tuples. We introduce formally the concept of polarized order dependencies (PODs). We discuss their potential significance for database systems, and present a chase procedure for testing logical implication for them.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <sec id="sec-1-1">
        <title>Consider the following SQL query in Example 1. EXAMPLE 1.</title>
        <p>select year, quarter, month, sales
from Sales s, Dates d
where s.date_id = d.date_id
group by year, quarter, month, sales
order by year asc, quarter asc, month asc, sales desc
In the schema, Dates is a dimension table with a row per day, and Sales is a large
fact table recording all individual sales. The column date_id is the primary key for
Dates, each row describes a given day with explicit columns as year, quarter,
month, and day that describe the natural date values.</p>
        <p>
          Of course, quarter is logically redundant in the group by, as month (which
follows it in the group by) functionally determines quarter. (First quarter
encompasses the months of January, February, and March, second quarter, the months
of April, May, and June, and so forth.) The query’s author could not leave quarter
out of the group by, because it is stated in the select. The query optimizer could,
however, remove quarter to accomplish the group by on year, quarter,
month, sales if it recognizes that year, month and year, quarter, month offer
the same partition. This is done by query optimizers today – given the functional
dependency (FD) information that month → quarter is available to the optimizer
– by rewrite [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ].
        </p>
        <p>For the query above, the rewrite might still not be applied, however since the query
also specifies the answers to be ordered by year asc, quarter asc, month
asc, sales desc. The FD that month → quarter is not logically sufficient
to eliminate quarter from the order by, as it was to eliminate it from the group
by. To see that the functional dependency does not suffice to eliminate quarter
from the order by, imagine the values for quarter were the strings first, second,
third, and fourth. Data would be lexicographically ordered as first, fourth, second,
then third! Of course, we intend that values of quarter are, say, 1, 2, 3, and 4, so
the data would order naturally as by date. It is unfortunate, then, that quarter is, in
fact, redundant (in this query) in the order by also, but that the optimizer does not
have the means to eliminate it. What is missing is the semantic information that
month asc orders quarter asc, which is more than just that month
functionally determines quarter. This states that as values rise from one tuple to another on
month, they must rise, or stay the same, from the one tuple to the other on quarter
(that is, the values do not descend from the one tuple to the other on quarter). The
order by criteria can be a mix of asc and desc (as in Example 1). With this
generalization we call it polarized order dependencies (POD). As best we know,
polarized order dependencies have not been studied before.</p>
        <p>
          Our objective is to bring a reasoning about PODs into the query optimizer. A query
plan for the query above could then eliminate quarter from both the order by
and the group by clauses. We are interested in PODs because polarized
(asc/desc) lexicographical orders are part of SQL via order by, and it is how
ordered tuple streams in a query are ordered. Therefore, PODs could be used to great
effect in query optimization. A first question for any class of a dependencies is the
inference problem: when does one POD logically follow from a collection of
prescribed PODs? In this paper, we present a chase procedure for testing logical
implication for PODs. Chase is a fixpoint algorithm enforcing satisfaction of data
dependencies in databases [
          <xref ref-type="bibr" rid="ref11 ref3">3, 11</xref>
          ]. The chase algorithm is used to reason about the consistency
and correctness of data design and in query optimization to rewrite queries.
Contributions. The main contributions of this paper follow. (Our work is the first
work on PODs.)
1. Applications. We demonstrate the utility of the PODs for database systems.
• We illustrate, the connection between PODs and the order by statement.
• We show how polarized order dependencies – a new type of integrity
constraint – can be used in query optimization.
2. Chase procedure. A chase procedure for polarized order dependencies for
lexicographical orders.
• We derive a chase procedure for polarized order dependencies over the sets
of tuples ordered lexicographically, the first such in the literature.
• We prove the soundness and completeness of chase rules for testing logical
implication.
        </p>
        <p>Outline. Section 2 provides background with our notational conventions and
definitions. We motivate PODs, and discuss practical applications of them. The core of the
paper is in Section 3, where we devise a chase procedure for testing logical
implication. Related work is presented in Section 4. In Section 5, we make concluding
remarks and discuss future work.</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>Background</title>
      <p>We adopt the notational conventions below. We consider a relation over the set
of attributes . Let be an arbitrary table instance over ; thus, a set of tuples
over ’s schema with attributes . We assume a column (#) in R that takes a unique
value per tuple, without loss of generality. This alleviates any need to work with a
table instance as bags of tuples; we consider them as sets. This also removes the
possibility that we might “lose” a row from r when we modify the value of one of its
columns (besides #), since # will still distinguish it from other tuples. Our notational
conventions are as follows.</p>
      <p>• Relations. A capital letter in bold italics represents a relation: R. Capital letters
represent single attributes: A, B, C. A small letter in bold represent a relational
instance: r. Tuples are marked with small letters in italics: s, t.
• Sets. Calligraphic letters stand for sets of attributes: , , . Proximity is used
for union of sets: is shorthand for ∪ . Likewise, A or A, where is
a set of attributes and A is a single attribute, stands for ∪ {A}. AB denotes {A,
B}.
• Lists. Bold letters stand for lists of attributes: , , . Note that list X could be
the empty list, []. Square brackets denote a list: [A, B, C]. The notation [A | Z]
denotes that A is the head of the list, and Z is the tail of the list, the remaining
list with the first element removed. Proximity is used for concatenation of lists
of attributes: is shorthand for ∘ . Likewise, A and A stands respectively
for [A] ∘ and ∘ [A], where is list of attributes and A is a single attribute. AB
denotes [A, B].
2.1</p>
      <sec id="sec-2-1">
        <title>Definition of PODs</title>
        <p>We consider ascending (asc) and descending (desc) order in the lexicographical
ordering. (This is part of the SQL’s standard). This also includes mixing of asc and
desc (e.g., order by X desc, Y asc). Our work can be also easily extended
to use of functions in the order directives (e.g., order by -1*X asc, Y asc).</p>
        <p>Definition 1. (marked attributes) For each attribute A, the marked attributes of A
are the formal symbols A and A.</p>
        <p>Marked attributes are used in the following way, giving us a polarization of
attributes.</p>
        <p>Definition 2. (operator ≼ and operator ≺ ) Let L be a list of marked attributes, s
and t be two tuples in relation instance r. Operator ≼ is defined as follows:
! ≼ "! where L = [H | Z]
if (H is of the form A and # &lt; "#)
or if (H is of the form A and # &gt; "#)
or if (( # = "#) and (Z = [] or ≼ " ))
Operator ≺ is defined as follows:
≺ " iff
≼
" and " ⋠
.</p>
        <p>We are now ready to define polarized order dependency.</p>
        <p>Definition 3. (polarized order dependency) Let X and Y be a list of marked
attributes. Call ↦ a polarized order dependency over the relation iff, for every pair
of permissible tuples s and t in relation instance over , ≼ " implies
≼ " .
and</p>
        <p>Whenever ↦ , we say that
↦ . We denote this by</p>
        <p>orders .
↔ .</p>
        <p>and
are order equivalent iff
↦
#
s
t</p>
        <p>The order of the attributes for FDs is not important. For PODs only particular
permutations of attributes may hold as dependencies because they are built on lists. The
order of the attributes is important as well as how they are polarized. PODs are
prescriptive statements on the relation, as are FDs. That is, they can be used as a type of
integrity constraint to prescribe which instances are admissible.</p>
        <p>EXAMPLE 2. Let r be a relation instance over with attributes {A, B, C, D, E} as
shown in Table 1. Note ⊨ ACD ↦ EB but ⊭ ACD ↦ BE. Furthermore, ⊨ CA ↦
BDE but ⊭ CA ↦ EBD.</p>
        <p>There is a relationship between PODs and FDs. We show that every POD infers a FD.</p>
        <p>THEOREM 1. (relationship between PODs and FDs) For every instance r of relation
R, if r satisfies OD ↦ , then r satisfies FD → (in which is the set of
attributes in X, and in Y).</p>
        <p>PROOF. Let s, t ∈ r, such that
definition of POD ≼ " and " ≼
= " . Therefore,
as ↦</p>
        <p>≼ " and " ≼
is given, hence
= " .</p>
        <p>. By the
THEOREM 2. (FD/POD correspondence) For every instance r of relation R, r ⊨
→ iff r ⊨ ↦ , for all lists that order the attributes of and all lists
likewise for .</p>
        <p>PROOF. (IF) If
flexivity, →
true.
(ONLY IF) If ↦ does not hold, there exists s, t ∈ r, such that
⋠PL " . This implies that = " and " ≺PL . Therefore ≠ " and
→ is not true.</p>
        <p>↦ , then → by Theorem 1. By Armstrong’s axiom
Reholds. Therefore, by Armstrong’s axiom Transitivity, → is
≼PL " but
= " ,
The concept of functional dependencies has come to have profound importance in
databases, especially in schema design. While functional dependencies are a simple
Note that the weakening rule
FDs and PODs are distinct.
2.2</p>
        <p>PODs in Databases
↦
implies
↦</p>
        <p>
          does not hold and as such,
notion in some ways, reasoning over them is, somewhat surprisingly, not nearly as
simple. To gain insight into how sets of FDs behave, and to simplify the reasoning
process over them, Armstrong provided an axiomatization for them [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. Beyond
layout and indexes, FDs play additional important roles in query optimization.
        </p>
        <p>We have introduced PODs in analogy to FDs: FDs are to group by as PODs are
to order by. Order plays pivotal roles on the physical side, in the physical database
and in query optimization. Data is often stored sorted by a clustered (tree) index’s
key. In a query plan, an operator that takes as input the output stream of another
operator can benefit in cases when the stream is sorted in a particular way. Given POD
↦ , if one has an SQL query with order by , one can rewrite the query with
order by instead, and meet the intent of the original query. However, the
rewritten query is not semantically equivalent to the original (unless ↔ )! One could not
legally rewrite the query with order by with order by instead. Strengthening
the order by conditions is permitted, but weakening them is not. (This is true too
inside query plans for ordered tuple streams.)</p>
        <p>A POD can be declared as an integrity constraint to prescribe which instances are
admissible. If one knows a collection of PODs, ℳ – declared as integrity constraints
over relation – one might soundly infer additionally PODs that must be true for
and use them for query optimization. For example, if ↦ and ↦ are true,
then ↦ is true also.</p>
        <p>Polarized order dependencies are not just limited to the time domain as used in
Example 1, however. They arise naturally in many other domains from the real-world
semantics associated with given data. Consider Example 3, which concerns taxes.</p>
        <p>EXAMPLE 3. Consider a table Taxes that includes columns for taxable income,
tax bracket, and taxes on the income. The tax brackets are based on the level on
income (the values of the tax brackets are: A, B, C, D and decrease with income
level). Assume taxes go up with income. Then, from [ income] ↦ [ bracket ] and
[income] ↦ [taxes] it follows that [income] ↦ [bracket, taxes]. Assume the table
has a tree (clustered) index on income. Given a query on the table with an order
by on bracket desc, taxes asc, with the POD above, it could be evaluated
using the index on income (for order by income asc), avoiding potentially
an expensive sorting operation.</p>
        <p>
          Instead of being columns with explicit data, bracket and taxes could be derived
by functions or case expressions – say, if Taxes were a view – or generated columns
in the table. In these cases, it would be possible for the database system to derive the
polarized order dependency constraints above automatically. In [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ], it was shown
how to derive such monotonicity “constraints” from generated columns via algebraic
expressions (in IBM DB2). Of course, one could prescribe the set of polarized order
dependencies as check constraints directly to benefit by this technique.
        </p>
        <p>
          In [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ], the authors expounded on the important role of order in query
optimization. They demonstrated numerous examples of how better reasoning over interesting
orders in the query optimizer could lead to significantly better performing query
plans. They introduced query rewrites in IBM DB2 that could replace one labeled
interesting order by another, when it is known the two order in the same way (that is,
are order equivalent, as we have defined it). For that, they use notion of FDs. They
showed how these rewrites could allow the optimizer to consider additional query
plans that process join, order by, group by, and distinct operators more
efficiently. However, they could not reduce the order by year asc, quarter
asc, month asc, sales desc to year asc, month asc, sales desc as
we did in Example 1, since their techniques do not employ the idea of PODs.
        </p>
        <p>
          By recognizing that a tuple stream ordered with respect to some criteria is
equivalently ordered with respect to other criteria, a sort on input can be removed for a
sortmerge join. Order by and group by operators can be satisfied with no need for a
sorting or partitioning operation more often. Likewise, as the distinct operator is
exchangeable with group by, the need for a sorting or partitioning operation to
satisfy distinct can be lessened. In [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ], they introduced a rewrite algorithm for
order by called Reduce Order. It sweeps the order by attribute list from right to
left, seeking to eliminate attributes. At each iteration through the list, the prefix set
with respect to the current attribute – that is, the set of attributes to the left of the
current – is checked to see whether it functionally determines the current attribute. If so,
the attribute is dropped from the list. We can augment that algorithm – call it Reduce
Order* – to do an additional step. At each iteration through the list, it can additionally
be checked whether any postfix list with respect to the current attribute – that is, the
list of attributes to the right of the current – orders the current attribute, where the
asc and desc gives us a polarization.
3
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>A Chase Procedure for PODs.</title>
      <p>A goal in any dependency theory is to develop algorithms for testing logical
implication; that is, testing whether a dependency is satisfied based on a given set of
dependencies. In this section, we show how to test logical implication for PODs using chase
procedure.</p>
      <p>Definition 4. (equalize) Let s and t be two tuples in relation instance r, and let A be
a single attribute. Also let x = min( #, "#). The operation equalize(r, A, s, t) returns a
relational instance r', with s and t modified in r so # = x and "# = x.</p>
      <p>EXAMPLE 4. Consider Table 2 and Table 3 as an example of an operation equalize.</p>
      <p>Definition 5. (chase rules) Let s and t be two tuples in relation instance r, and let X
and Y be lists of marked attributes such that X ↦ Y is falsified in r ( ≼ " but
⋠ " ), let A be the first attribute in X such that # ≠ "# (if such an attribute A
exists) and let B be first attribute in Y such that "B ≠ B . Two chase rules are defined.
• Split rule: If = " , then r' = equalize(r, B, s, t).
• Swap rule: If # ≠ "# and B ≠ "B , then r' = equalize(r, B, s, t).</p>
      <p>EXAMPLE 5. Let ℳ = {A ↦ BC, B ↦ C} and let r be an instance over R with
attributes {A, B, C}. From Table 4 to Table 5 demonstrates an example of applying the
split rule (A ↦ BC is falsified in r in Table 4). From Table 5 to Table 6 demonstrates
applying the swap rule (B ↦ C is falsified in r' in Table 5).</p>
      <p>Let ℳ be a set of prescribed PODs, and let r = {"C, … , "E} be an instance relation over
R. The chase algorithm is as follows.</p>
      <sec id="sec-3-1">
        <title>Algorithm 1 (chase(r, ℳ))</title>
        <p>Current := r;</p>
        <p>Previous := {}; //empty instance
while Current ≠ Previous {</p>
        <p>Previous := Current;
if (∃ t,s ∊ Current, ∃ X ↦ Y in ℳ such that ≼ " but t ⋠ " ) {
Apply one of the chase rules (split or swap from Definition 5) to s and t,
assigning the table which is returned from equalize operation to Current.
}
} return Current;</p>
        <p>EXAMPLE 6. Let ℳ = {A ↦ BC, B ↦ C} be a set of PODs and r an instance over R
with attributes {A, B, C}. The sequence from Table 4, Table 5, to Table 6 is an
example of applying Algorithm 1 (chase(r, ℳ)) to r as in Table 4. In Table 6, there is no s
and t that matches (as in step 5 of Algorithm 1), so the procedure terminates with it.</p>
        <p>PROOF. Consider a given relational instance r, and any relational instance s, over
schema R. Without loss of generality let all values in r and s be zero or greater. Let
∑L be the sum of all the values of all the columns in s. Let there be an applicable
chase rule – split or swap – on s with respect to ℳ, and s' be the result of its
application. Instance s' has the same number of rows as s. Also ∑LM &lt; ∑L as the equalize
replaced a value in some column of some row by a smaller value. (Note that equalize
does not introduce new values.) Zero is the lower bound on the ∑LM. As a chase
procedure is a finite sequence of such transformations starting with r, it must terminate.
#
s
t
u</p>
        <p>The remaining step is to show that the resulting table of Algorithm 1 satisfies a set
of PODs ℳ. The instance chase(r, ℳ) satisfies ℳ as no split or swap with respect to
ℳ applies. If not the chase procedure would not have terminated at that point. □</p>
        <p>THEOREM 3. Let relation instance r be over R and let ℳ be a set of PODs. Then
r ⊨ ℳ iff r = chase(r, ℳ).</p>
        <p>PROOF. (IF): If any split or swap applies to table instance s with respect to ℳ, for
the resulting s', ∑LM &lt; ∑L. Then clearly s ≠ s'. Thus r = chase(r, ℳ) if no swap or
split applies, meaning r ⊨ ℳ. (ONLY IF): From Definition 5 it follows that chase
rules split or swap are only used if it breaks a dependency in ℳ. □
Let us define a table template.</p>
        <p>Definition 6. (table template) Let R be relation schema with n attributes and m be a
POD ↦ , where list of marked attributes contains attributes [XC, … , XP ]. A table
template for a POD m, denoted as Q, is a table consisting of two tuples s and t, such
that is either equal to R or S, for j in 1,..., k. In R and S, symbols pT and qT
represents one of the following three cases, where the ordering of variables bT and tT is
defined as bT &lt; tT:
#
s
t
a)
b)
c)
XC
bC
bC
pT = bT and qT = bT,
pT = bT and qT = tT,
pT = tT and qT = bT.</p>
        <p>Definition 7. (mapping Q to ö( Q)) Let Q be a table template from Definition 6. A
mapping of Q to ö( Q) is any instance with values that satisfy the ordering from
Definition 6.</p>
        <p>EXAMPLE 7. Consider Table 9 as one of possible mappings from Definition 7. (In
fact it can be any relation instance which satisfies the Definition 6 of ordering of
variables).</p>
        <p>PROOF. The proof follows directly from Theorem 3 by replacing Q with r and
applying chase rules split and swap on variables bT, tT using ordering defined in
Definition 6. □
LEMMA 3. Let Q be a table template from Definition 6 and ö( Q) be mapping from
Q (Definition 7). Then Q ⊨ X ↦ Y iff ö( Q) ⊨ X ↦ Y.</p>
        <p>PROOF. The proof follows from the definition of ordering of variables in Definition
6. Since ordering of values in ö( Q ) corresponds with ordering of variables in Q
respectively (Definition 7). □</p>
        <p>Definition 8. (tableaux c Q) Let m be a POD X ↦ Y. We define c Q to be the set of
all table templates Q, as defined in Definition 6.</p>
        <p>Note that c Q is not just a single table template. It is a set of table templates (each
consisting of two rows). The chase of c Q is defined as follows.</p>
        <p>Definition 9. (chase of tableaux c Q) The chase of c Q over a set of PODs ℳ,
denoted as CHASEc f ,ℳ is defined by CHASEc f ,ℳ = {chase( Q, ℳ) | Q ∊ c Q }.
CHASEc f ,ℳ satisfies X ↦ Y, denoted by CHASEc f ,ℳ⊨ X ↦ Y, if, for all Q ∊ c Q,
chase( Q, ℳ) ⊨ X ↦ Y. CHASEc f ,ℳ satisfies ℳM denoted by CHASEc f ,ℳ ⊨ ℳ', if
for all X ↦ Y ∊ ℳ', CHASEc f ,ℳ⊨ X ↦ Y.</p>
        <p>THEOREM 4. (chase procedure for PODs is sound and complete) Let ℳ be a set of
PODs over R and m be a POD X ↦ Y. Then ℳ ⊨ X ↦ Y iff CHASEc f ,ℳ ⊨ X ↦ Y.</p>
        <p>PROOF. (IF): Assume CHASEc f ,ℳ ⊭ X ↦ Y. By Definition 9, there exists
Q ∊ c Q, such that chase( Q, ℳ) ⊭ X ↦ Y. Note chase( Q, ℳ) ⊨ ℳ, by Lemma 1.
Hence, there is a mapping ö to generate a relation instance ö(chase( Q, ℳ)) and by
Lemma 3, ö(chase( Q, ℳ)) ⊨ ℳ, but ö(chase( Q, ℳ)) ⊭ X ↦ Y. This implies that
ℳ ⊭ ↦ because we have found a relation instance which satisfies ℳ but does
not satisfy ↦ . Therefore, if ℳ ⊨ X ↦ Y then CHASEc f ,ℳ ⊨ X ↦ Y.
(ONLY IF): Assume CHASEc f ,ℳ⊨ ↦ . Let s, t be any two tuples in any relation
r such that ≼ " and satisfying ℳ. We would like to present that ≼ " . Let
Q ∊ c Q, let Q = {p, q} be the template relation such that ö(p) = s and ö(q) = t. It is
possible always to find such a pair of tuples Q since c Q considers all possibilities of
two tuples which satisfy the condition ≼ " . Therefore, we have ö( Q) = {s, t}
and ö( Q ) ⊨ ℳ . By Lemma 3, it follows that Q ⊨ ℳ . Therefore, it follows by
Lemma 2 that Q = chase( Q, ℳ). Since we have assumed that CHASEc f ,ℳ⊨ ↦ ,
we have chase( Q , ℳ ) ⊨ ↦ . As ö ( Q ) = ö (chase( Q , ℳ )), it implies that
ö( Q) ⊨ ↦ by Lemma 3. So ≼ " . Hence, if CHASEc f ,ℳ ⊨ X ↦ Y, then ℳ
⊨ X ↦ Y. □
THEOREM 5. (decidable) The implication problem of the PODs is decidable.</p>
        <p>PROOF. Testing implication problem of the PODs is decidable as the chase
procedure is a sound and complete inference algorithm for PODs (Theorem 4). □</p>
        <p>THEOREM 6. (complexity of chase procedure for PODs) The complexity of building
templates is exponential for the PODs chase procedure.</p>
        <p>PROOF. According to Definition 6 there are 3hZP templates for R and 3hZS
templates for each, S . Therefore there are 3hZP + (3hZP +…3hZC ) templates in total.
Because (3hZP +…+ 3hZC ) is geometric progression this can be simplified to the form
3hZP + 3hZP (1 - 3P )/(1-3) which is equal to (3h + 3hZP )/2. So the complexity of
building the templates is shown to be O(3E ). □
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Related Work</title>
      <p>
        Ordered sets and lattices have been a subject of research in mathematics. Our
concept of polarized order dependency is equivalent to order-preserving mappings
between ordered sets [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. The work in mathematics has concentrated on investigating
properties of, and relationships between, ordered sets rather than among the
mappings. To the best of our knowledge, no inference system for describing relationships
between mappings has been proposed.
      </p>
      <p>
        Order dependencies were introduced for the first time in the context of database
systems in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. However, the type of orders, hence the dependencies defined over
them, were different from the ones we presented here. A dependency1 ↝ holds
if order over the values of each attribute in implies an order over the values of each
attribute of . This dependency is defined over the sets of attributes then, rather than
lists. The distinction between these two types of dependencies was later aptly
described as pointwise versus lexicographical order dependency [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]. An instance of a
database satisfies a pointwise order dependency ↝ if, for all tuples s and t, for
every attribute A in , s[A] op t[A] implies that for every attribute B in ,
s[B] op t[B], where op ∈ {&lt;, =, &gt;, ≤, ≥}. In [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], a sound and complete set of inference
rules for such dependencies is defined together with an analysis of the complexity of
determining logical implication. A practical application of the dependencies for an
improved index design is presented in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>
        Dependencies defined over lexicographically ordered domains were introduced in
[
        <xref ref-type="bibr" rid="ref14">14</xref>
        ] under the name lexicographically ordered functional dependencies. The order
dependencies are defined as we do in this paper, but do not concern polarization (a
mix of asc and desc). Call these all-ascending order dependencies. A set of
inference rules (proved to be sound and complete) is introduced for pointwise
dependencies (simpler than the one defined in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]), but not for all-ascending order
dependencies. A chase procedure is defined for the latter. In [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ], we presented an
axiomatization for all all-ascending order dependencies, and proved the axiomatization to be
sound and complete. An interesting extension of relational algebra to ordered domains
is presented in [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. Our work is the first work on PODs.
      </p>
      <p>
        Sorting is at the heart of many database operations: for instance sort-merge join,
index generation, duplicate elimination and ordering the output through the SQL
order by operator. The importance of sorted sets for query optimization and
processing has been recognized very early on. The query optimizer of System R [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ] paid
particular attention to interesting orders by keeping track of all such ordered sets
      </p>
      <sec id="sec-4-1">
        <title>1 For simplicity, we use the arrow ↝ for any different type of orders.</title>
        <p>
          throughout the process of query optimization. In more recent work, [
          <xref ref-type="bibr" rid="ref10 ref9">9, 10</xref>
          ] explored
the use of sorted sets for executing nested queries. The importance of sorted sets has
prompted the researchers to look beyond the sets that have been explicitly generated.
Thus, [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ] shows how to discover sorted sets created as generated columns2 via
algebraic expressions. For example, if column A is sorted, so is the generated column G
defined as G = A/100 + A − 3 (that is, A ↝ G). We show in [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ] how to use
relationships between sorted attributes discovered by reasoning over the physical schema.
The chase presented here provides a formal way of discovering) previously unknown
sorted sets. Based on this work, many other optimization techniques from relational
query processing can also be adapted.
5
        </p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Conclusions</title>
      <p>While order of tuples is purposely excluded in the relational model – an answer to a
query is a set of tuples – order plays a vital role in the evaluation of queries and in
real-world query languages as SQL with order by. (In other data/query models,
order is part of semantics, as for XML/XQuery.) We provide a sound and complete
chase procedure for the inference problem for PODs. The goal of this work was to
develop a theory behind dependencies over polarized lexicographically ordered sets.
To the best of our knowledge, this is the first attempt to develop a procedure for
testing logical implication for PODs. We explored some correspondence between FDs
and PODs. The story of PODs is not over. We plan next to pursue the following.
•</p>
      <p>
        We would like to extend our work for all-ascending order dependencies [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ] into
an axiomatization for polarized (asc/desc) order dependencies. Such an
axiomatization can provide insight into how PODs behave to devise useful, logically
sound rewrites rules for queries. An axiomatization also can provide basis for
developing an efficient theorem prover (inference procedure) for PODs.
• Our chase procedure demonstrates the inference procedure is decidable (Theorem
5), but it is not efficient (Theorem 6). We would like an efficient theorem prover
[
        <xref ref-type="bibr" rid="ref1 ref11">1, 11</xref>
        ]. Given a set of PODs ℳ and an arbitrary dependency ↦ we would like
to efficiently decide whether ℳ logically implies ↦ . Such a theorem prover
would be a useful tool for the use of PODs in query optimization. (An
axiomatization, as discussed above, could be instrumented for this.)
• Integrity constraints have been widely used in query optimization through query
rewrites. For example, functional dependencies have been shown to be useful in
simplifying queries with distinct, order by, and group by operations
[
        <xref ref-type="bibr" rid="ref16">16</xref>
        ], whereas inclusion dependencies can be used to remove certain joins over
primary and foreign keys [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Polarized order dependencies can be used in similar
ways to simplify queries with the order by operation [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ].
• It is possible PODs have a role in database design [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Functional dependencies are
by far the most common integrity constraints in the real world. The notion of the
key derived from a given set of FDs is a fundamental to the relational model. The
2 In DB2, a generated column is a column that can be computed from other columns in the schema.
determination of polarized order dependencies might be an important part of
designing databases in the relational model, too. It can be used in database
normalization and denormalization. Polarized order dependencies can reveal redundancies
that cannot be detected using functional dependencies alone. It would be an
interesting research topic to extend the results obtained there to the design of relational
databases.
      </p>
      <p>Acknowledgments. We thank Calisto Zuzarte and Wenbin Ma from IBM laboratory
in Toronto for their encouragement and helpful suggestions throughout the project.
6</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Armstrong</surname>
            ,
            <given-names>W.W.</given-names>
          </string-name>
          ,
          <year>1974</year>
          ,
          <article-title>Dependency structures of data base relationships</article-title>
          .
          <source>In Proceedings of the IFIP Congress</source>
          , Stockholm,
          <fpage>580</fpage>
          -
          <lpage>583</lpage>
          , North-Holland
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Abiteboul</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hull</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vianu</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <year>1995</year>
          . Foundations of Databases. Addison-Wesley Publishing Company, Inc.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Aho</surname>
            ,
            <given-names>A.V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sagiv</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ullman</surname>
            ,
            <given-names>J.D.</given-names>
          </string-name>
          ,
          <year>1979</year>
          .
          <article-title>Equivalence of relational expressions</article-title>
          .
          <source>SIAM J. Comptng.</source>
          ,
          <fpage>218</fpage>
          -
          <lpage>246</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Bernstein</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <year>1976</year>
          .
          <article-title>Synthesizing third normal from relations</article-title>
          .
          <source>ACM TODS</source>
          ,
          <volume>277</volume>
          -
          <fpage>298</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5. Cheng,
          <string-name>
            <given-names>Q.</given-names>
            ,
            <surname>Gryz</surname>
          </string-name>
          . J.,
          <string-name>
            <surname>Koo</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Leung</surname>
            , T.Y.C, Liu,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Qian</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schiefer</surname>
            ,
            <given-names>K.B.</given-names>
          </string-name>
          ,
          <year>1999</year>
          .
          <article-title>Implementation of Two Semantic Query Optimization Techniques in DB2 Universal Database</article-title>
          . VLDB.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Davey</surname>
            ,
            <given-names>B.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Priestley</surname>
            ,
            <given-names>H.A.</given-names>
          </string-name>
          ,
          <year>2002</year>
          .
          <article-title>Introduction to Lattices and Order (2</article-title>
          . ed.). Cambridge University Press,
          <fpage>1</fpage>
          -
          <lpage>298</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Dong</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hull</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <year>1982</year>
          .
          <article-title>Applying Approximate Order Dependency to Reduce Indexing Space</article-title>
          . SIGMOD Conference,
          <volume>119</volume>
          -
          <fpage>127</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Ginsburg</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hull</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <year>1981</year>
          .
          <article-title>Ordered Attribute Domains in the Relational Model</article-title>
          .
          <source>XP2 Workshop on Relational Database Theory.</source>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Graefe</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <year>2003</year>
          . Executing Nested Queries.
          <article-title>Datenbanksysteme für Business, Technologie und Web, Tagungsband der 10</article-title>
          . BTW-Konferenz,
          <fpage>58</fpage>
          -
          <lpage>77</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Guravannavar</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ramanujam</surname>
            ,
            <given-names>H.S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sudarshan</surname>
            ,
            <given-names>S</given-names>
          </string-name>
          ,
          <year>2005</year>
          .
          <article-title>Optimizing Nested Queries with Parameter Sort Orders</article-title>
          . VLDB,
          <fpage>481</fpage>
          -
          <lpage>492</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Maier</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mendelzon</surname>
            <given-names>A.O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sagiv</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <year>1979</year>
          .
          <article-title>Testing implication of data dependencies</article-title>
          .
          <source>ACM Transactions on Database Systems</source>
          ,
          <volume>455</volume>
          -
          <fpage>469</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Malkemus</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Padmanabhan</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bhattacharjee</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cranston</surname>
            ,
            <given-names>L</given-names>
          </string-name>
          ,
          <year>2005</year>
          .
          <article-title>Predicate Derivation and Monotonicity Detection in DB2 UDB</article-title>
          . ICDE,
          <fpage>939</fpage>
          -
          <lpage>947</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Ng</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <year>1999</year>
          .
          <article-title>Lexicographically Ordered Functional Dependencies and Their Application to Temporal Relations</article-title>
          .
          <source>IDEAS 279-287.</source>
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Ng</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <year>2001</year>
          .
          <article-title>An extension of the relational data model to incorporate ordered domains</article-title>
          .
          <source>ACM Trans. Database Syst</source>
          .,
          <fpage>344</fpage>
          -
          <lpage>383</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Selinger</surname>
            ,
            <given-names>P.G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Astrahan</surname>
            ,
            <given-names>M.M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chamberlin</surname>
            ,
            <given-names>D.D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lorie</surname>
            ,
            <given-names>R.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Price</surname>
            ,
            <given-names>T.G.</given-names>
          </string-name>
          ,
          <year>1979</year>
          .
          <article-title>Access Path Selection in a Relational Database Management System</article-title>
          .
          <source>SIGMOD Conference</source>
          ,
          <volume>23</volume>
          -
          <fpage>34</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Simmen</surname>
            ,
            <given-names>D.E</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shekita</surname>
            ,
            <given-names>E.J.</given-names>
          </string-name>
          ,
          <source>Malkemus</source>
          ,
          <year>1996</year>
          .
          <article-title>Fundamental Techniques for Order Optimization</article-title>
          . SIGMOD,
          <fpage>57</fpage>
          -
          <lpage>67</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>Szlichta</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Godfrey</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gryz</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , Ma,
          <string-name>
            <given-names>W.</given-names>
            ,
            <surname>Pawluk</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Zuzarte</surname>
          </string-name>
          ,
          <string-name>
            <surname>C.</surname>
          </string-name>
          ,
          <year>2011</year>
          ,
          <article-title>Queries on dates: fast yet not blind</article-title>
          .
          <source>EDBT 497-502.</source>
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <surname>Szlichta</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Godfrey</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gryz</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <year>2012</year>
          , Fundamentals of Order Dependencies. VLDB.
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <surname>Ullman</surname>
            ,
            <given-names>J.D.</given-names>
          </string-name>
          ,
          <year>1988</year>
          .
          <article-title>Principles of Database and Knowledge-Base Systems</article-title>
          , Vol. I,
          <fpage>378</fpage>
          -
          <lpage>379</lpage>
          , Computer Science Press, Rockville, MD,
          <fpage>376</fpage>
          -
          <lpage>423</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>