Re: What is Aggregation? Re: grouping in tuple relational calculus
Date: Fri, 18 Feb 2005 17:47:26 -0800
Message-ID: <r5xRd.38$o%4.138_at_news.oracle.com>
"Vadim Tropashko" <vadimtro_invalid_at_yahoo.com> wrote in message
news:1108775777.801768.322550_at_o13g2000cwo.googlegroups.com...
> A set is a bag that has its all element counted once only. A bag is a
> list that has its element ordered.
>
> In other words, aggregation (with group by) maps a category of bags
> into sets. For example,
>
> select figure from
> {circle, circle, square, triangle}
> group by figure
>
> is a projection of a bag
>
> {circle, circle, square, triangle}
>
> into a set
>
> {circle, square, triangle}
>
> Likewise, ordering is a mapping of lists into bags. E.g.
>
> select figure from
> circle->square->circle->triangle
> order by figure
>
> would produce a bag
>
> {circle, circle, square, triangle}
Well, the analogy is not quite complete. In your example, the mapping is an extended projection that creates an extra column:
select figure, sum(1) from
{circle, circle, square, triangle}
group by figure
From from the projection enhanced with the counter, we can restore the
original multiset back.
Then, perhaps, ordering creates a pseudocolumn with a similar purpose too?
Well, it's not a hard to figure out what this column should be. The ordering
example should look like this
select figure, seq# from
with the return result
circle->square->circle->triangle
order by figure
(circle,1)
(circle,3)
(square,2)
(triangle,4)
Similar to the previous case by knowing this multiset we can restore the original list back.
BTW sequence generators are common in the SQL DBMS world. They are hacks without any foundation, of course. Received on Sat Feb 19 2005 - 02:47:26 CET