Re: Relational Algebra and Aggregate Functions

From: Robert James <srobertjames(at)gmail(dot)com>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Relational Algebra and Aggregate Functions
Date: 2009-07-28 13:14:38
Message-ID: e09785e00907280614g42bb5257w7e8f0a9e9513fc15@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Many wrote that the functional programming 'fold' is a good model for
relational aggregate functions. I have a few difficulties with this:
1. fold doesn't offer any type of GROUP BY, which is an essential component
of aggregation.
2. I don't believe fold can handle things like AVG() or STDDEV(). Can it?
Conversely, fold can handle non-commutative and non-associative operators,
which I don't believe can be used for aggregation.
3. fold is defined on sequences, not sets. This doesn't seem to be a
problem until you think about cases where there a duplicates of the
aggregated field. (For instance, there are 10 bags each weighing 5 lbs, and
you want SUM(weight) - you need to project weight onto a collection which
allows for 10 occurences, or define the aggregate function to work on the
whole tuple somehow... I know a man named Krug worked out a formal theory
for this...)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert James 2009-07-28 13:22:53 Re: Clients disconnect but query still runs
Previous Message blackwater dev 2009-07-28 13:12:08 selecting all columns but one