Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Extending my question. Was: The relational model and relational algebra - why did SQL become the industry standard?

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

From: Jan Hidders <jan.hidders_at_REMOVE.THIS.ua.ac.be>
Date: 7 Mar 2003 11:01:14 +0100
Message-ID: <3e686dea.0@news.ruca.ua.ac.be>


Lauri Pietarinen wrote:
>Jan Hidders wrote:
>> Let's say I have a set X and I want to know the average of f(x) for all x
>> in the set X. In the bag algebra this is straightforward: an iteration
>> over X where you compute f(x), followed by the bag function AVG. If you
>> simulate this with sets ( the bag {{x, x, y}} becomes {(x,2), (y,1)} )
>> then you get an iteration followed by a grouping on the values of f(x)
>> and then you have to compute the average over the product of every
>> element and its cardinality. It's not trivial to recognize that this is
>> equivalent with the previous sequence of bag operations, which is often a
>> more efficient implementation.
>
>Could you clarify?
>
>In "SQL-speak" what would this mean?
>
>Something like this?
>
>-- "tuple bag" version
>SELECT AVG(F(x))
> FROM X;
>
>instead of
>
>-- "set" version
>SELECT AVG'( fx, count )
> FROM (
> SELECT F(x) as fx, count(*) as count
> FROM X
> GROUP BY x )
>
>??

Yes. With the correction you yourself already gave that the final GROUP BY should be on fx.

Received on Fri Mar 07 2003 - 04:01:14 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US