| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: does a table always need a PK?
"Lee Fesperman" <firstsql_at_ix.netcom.com> wrote in message
news:3F5452A0.1AB_at_ix.netcom.com...
> Bob Badour wrote:
> >
> > "Lee Fesperman" <firstsql_at_ix.netcom.com> wrote in message
> > news:3F510C49.2A6E_at_ix.netcom.com..
> > > Bob Badour wrote:
> > > > Does the mathematical identity "SUM(A)+SUM(B)=SUM(A+B)" demonstrate
> > > > a flaw or limitation of SQL's NULL?
> > >
> > > No, if you ignore the empty set issue.
> >
> > I am surprised by this answer, because I know we have discussed it
before.
> > Given the following table, T:
> >
> > A B
> > = =
> > 1 2
> > 3 NULL
> > NULL 4
> >
> > What are the results of the following queries?
> >
> > select SUM(A) from T;
> > select SUM(B) from T;
> > select SUM(A+B) from T;
> >
> > Am I missing something?
>
> I didn't intend to mislead.
I know. Even if you had tried to avoid one question, I would conclude you are only human and intellectually honest on balance. It's not like you tried to avoid most of the questions or made any specious claims for your product or tried to deny the possibility of there being other decent vendors out there.
> I decided against a longer response to keep all the answers
> succinct.
>
> I answered 'no' because I consider it an inherent of aspect of NULL
processing rather
> than a flaw or limitation. IOW, I am saying that the sub-expression above
is not an
> identity when either A or B can contain a NULL.
>
>
>
>
>
> A B C
> = = =
> 1 2 3
> 3 NULL NULL
> NULL 4 NULL
>
>
>
>
That's not what I would expect. I was under the impression SQL would simply omit any rows with a NULL in any SUM expression. In this case, I would expect the sums to result in 1+2=3 preserving the identity. It is only when evaluating the sums separately that I would expect the identity to fail.
> SUM(A) is the sum of the values -- A from tuple 1, A from tuple 2, A from
tuple 3.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
Would you agree, then, that NULL and coalesce might place an additional cognitive burden on the user ? Received on Tue Sep 02 2003 - 08:03:38 CDT
![]() |
![]() |