Aggregates on empty groups.

From: Mikito Harakiri <mikharakiri_nospaum_at_yahoo.com>
Date: 1 Aug 2004 12:10:37 -0700
Message-ID: <8a529bb.0408011110.4212e777_at_posting.google.com>


nzanella_at_cs.mun.ca (Neil Zanella) wrote in message news:<b68d2f19.0407311115.1214688a_at_posting.google.com>...
> Mathematicians like to define a sum operator on finite sets in such a way
> that the sum of a finite set is equal to the sum of all elements in the set.
> Next they would like such operator to have the property that the sum operator
> is distributive over disjoint finite partitions of sets. Since disjoint finite
> partitions can involve any finite number of empty sets, they then go on to
> define the sum of an empty set to be zero, just so that they can say what
> they wanted to say about the sum operator, namely that it is distributive
> over finite partitions of sets. So, they make the definition suit the
> world they like to create for themselves.

Simple aggregate is easy. It's "group by" that challenges consistency of the whole approach. Indeed, empty set becomes empty group, therefore, shouldn't we label with 0 every value in the domain that is missing in the relation?!

Example:

select dept, sum(sal) from emp
group by dept

Accounting 200000
Engineering 1000000
............ and departments that are not in emp relation: Finance 0

Note that the problem of domain dependency is easily solved if we declare the aggregate on empty set to be the empty set.

When working with aggregates it might be desirable to consider empty set and the record with sum=0 as equivalent from math perspective... Received on Sun Aug 01 2004 - 21:10:37 CEST

Original text of this message