Re: Relational Algebra and Aggregate Functions - Mailing list pgsql-general

From Robert James
Subject Re: Relational Algebra and Aggregate Functions
Date
Msg-id e09785e00907280614g42bb5257w7e8f0a9e9513fc15@mail.gmail.com
Whole thread Raw
In response to Re: Relational Algebra and Aggregate Functions  (Sam Mason <sam@samason.me.uk>)
Responses Re: Relational Algebra and Aggregate Functions
List 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...)

pgsql-general by date:

Previous
From: blackwater dev
Date:
Subject: selecting all columns but one
Next
From: Merlin Moncure
Date:
Subject: Re: selecting all columns but one