June 2002

Aggregation Semantics

Introduction

Aggregation on One Field

Aggregation on Many Fields

Here is the table definition for an aggregate
Aggregate  
  Aggregation Type
  Field to Aggregate
  Source Table

Here is the table to store the group by fields, note many to one relation to the aggregate
Group By  
  Key of Aggregate
  Field to group by

We must be able to store the result
Result  
  Grouped Field Value1
  Grouped Field Value 2
  ...
  Grouped Field Value n
  Aggregate Result

If we chose more than one aggregation type on the same source table, with the same fields grouped we would notice a certain similarity between the Result and Result 2 tables
Result2  
  Grouped Field Value 1
  Grouped Field Value 2
  ...
  Grouped Field Value n
  Aggregate Result2

These two results are duplicating record entries and can be optimized by combining them into a single table, or identifying thier common grouped fields as a seperate entity, a Space. The latter option is better because it identifies tables with muti-attribute keys.
Result Point 1  
  Point
  Aggregate Result

Result Point 2  
  Point
  Aggregate Result2

Point  
  Grouped Field Value 1
  Grouped Field Value 2
  ...
  Grouped Field Value n

The point class is actually declaring a Space. There is allowed only one record with a given combintion of field values. Each space must be a class to declare the fields that make up the various dimensions of the space.

Back to our naive 2-table structure at the top. We notice that the same aggregate can be defined for different tables. Maybe the count aggregate, to count the number of record in a table is used often. We can easily the functional dependency between "Source Table" and the "Field to Aggregate". The Aggregate structure must be broken into two structures:

Aggregate Class  
  Aggregation Type
  Field to Aggregate

Aggregate Table  
  Source Table
  Aggregate Class