| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Counting propositions
x wrote:
>> If columns a & b combined are a candidate key, we want to say
>> something like: "select count(a,b) from R" but I don't think this
>> is legal syntax in SQL. Maybe it should be? Are there reasons why
>> not?
> > So we really want to count just the candidate keys, not the > propositions ?
Counting the candidate keys is equivalent to counting the propositions. I just think that extending the count syntax to multiple columns feels a neater way of generalising it. count(*) seems a bit of an anomaly because it kind of operates on a relation instead of the data within the relation.
>> If you think of "*" as a wildcard that expands to all the columns,
>> "select count(*) from R" would be literally like "select
>> count(a,b,c) from R" which might be useful if you couldn't
>> instantly remember what the candidate keys were and couldn't be
>> bothered to look them up. Similar to the "select * from R" syntax.
> > But if you only intended "select count(distinct a,b,c)" instead of > "select count(*)", if the candidate key change you are in trouble.
Certainly, I'm just thinking of its ad-hoc interactive uses in a similar way to how "select *" is used.
> There is a need for select count(*) (other than as a replacement for > "select count(distinct a,b,c)" ) ?
I don't think so. Just as there's not really a need for "select *".
>> I know that it has been said COUNT is redundant because it can be
>> done with SUM. But counting is a much more fundamental concept
>> logically. Any domain can be counted. SUM requires a domain with
>> all the arithmetic structure to define addition. So COUNT is purer:
>> it can exist independently of domains whereas SUM requires
>> cooperation from the domains.
> > Well, not any domain can be counted and for counting a domain, you > need the natural numbers anyway.
In a database context every domain can be counted surely, since it has finite storage space? Though what I really meant was that in any relation, the number of distinct values in a column can be counted irrespective of the domain.
> Have you guessed right what is the meaning of "s(X)" in the Prolog > code I posted ?
No, I'm having a look at it though and having to learn the syntax. I think I understand that square brackets indicate lists and the underscore is like an unbound variable. I'm guessing that R and L might mean right and left in this case?
Paul. Received on Mon Jun 21 2004 - 18:08:06 CDT
![]() |
![]() |