Abstract

We study the problem of efficient maintenance of materialized views that may
contain duplicates. This problem is particularly important when queries against
such views involve aggregate functions, which need duplicates to produce correct
results. Unlike most work on the view maintenance problem that is based on an
algorithmic approach, our approach is algebraic and based on equational reasoning.
This approach has a number of advantages: it is robust and easily extendible to
new language constructs, it produces output that can be used by query optimizers,
and it simplifies correctness proofs.

We use a natural extension of the relational algebra operations to bags
(multisets) as our basic language. We present an algorithm that propagates
changes from base relations to materialized views. This algorithm is based on
reasoning about equivalence of bag-valued expressions. We prove that it is
correct and preserves a certain notion of minimality that ensures that no
unnecessary tuples are computed. Although it is generally only a heuristic that
computing changes to the view rather than recomputing the view from scratch is
more efficient, we prove results saying that under normal circumstances one
should expect, the change propagation algorithm to be significantly faster and
more space efficient than complete recomputing of the view. We also show that our
approach interacts nicely with aggregate functions, allowing their correct
evaluation on views that change.