Re: Extending my question. Was: The relational model and relational algebra - why did SQL become the industry standard?

From: Mikito Harakiri <mikharakiri_at_ywho.com>
Date: Thu, 13 Feb 2003 16:54:15 -0800
Message-ID: <jcX2a.16$O%2.38_at_news.oracle.com>


"Bob Badour" <bbadour_at_golden.net> wrote in message news:4uW2a.1409$0G3.168661119_at_mantis.golden.net...
> "Mikito Harakiri" <mikharakiri_at_ywho.com> wrote in message
> news:irT2a.10$O%2.40_at_news.oracle.com...
> > Not
> > for aggregates:
> >
> > PROJECTION*AGGREGATE != AGGREGATE*PROJECTION
> >
> > for example
> >
> > select distinct S from (
> > select distinct SUM(SAL) from emp
> > )
> >
> > is not the same as
> >
> > select distinct SUM(SAL) from (
> > select distinct SAL from emp
> > )
> >
> > where i'm using SQL with the "distinct" keyword merely as a surrogate
for
> > true relational syntax ("distinct" is redundant after aggregate
operation,
> > of course).
>
> Why should the sum of all salaries equal the sum of distinct salaries?

In set model they don't. In the bag model, however, we rewrite the above identity without the "distinct" keyword:

select S from (

   select SUM(SAL) S from emp
)

is the same as

select SUM(SAL) from (

   select SAL from emp
)

Once again, this means that PROJECTION and AGGREGATE commute in the bag model. Received on Fri Feb 14 2003 - 01:54:15 CET

Original text of this message