Re: constraints in algebra instead of calculus

From: Jon Heggland <jon.heggland_at_idi.ntnu.no>
Date: Sun, 17 Jun 2007 11:10:05 +0200
Message-ID: <f52tpd$fal$1_at_orkan.itea.ntnu.no>


paul c wrote:
> I think you are suggesting:
>
> R{B} GROUP {B} as gB:
> gB
> {2,3}
>
> where the result has one row.

Yes. In general, any R{X} GROUP {X} as gX will produce a relation with one tuple, containing a sole attribute gX with R{X} as its value. (Unless R{X} is empty, of course.)

> It looks to me that the TTM def'n,
>
> "Let relation r have attributes A, B, ..., C, D, E, ..., F. Then the
> Tutorial D <group>
> r GROUP ( { D, E, ..., F } AS X )
> is shorthand for the Tutorial D expression
> ( EXTEND r ADD ( r AS RR , RELATION { TUPLE { A A, B B, ..., C C } } AS
> TX , RR COMPOSE TX AS X ) ) { A, B, ..., C, X }
> (where RR and TX are attribute names not already appearing in r),
> and can therefore be expressed in A."
>
> I read that as meaning that the COMPOSE joins the original relation with
> each original tuple,

No, it joins the original relation with (a singleton relation containing) a tuple consisting of the non-grouped attributes of each original tuple---note that the TUPLE expression only includes A, B, ..., C; not D, E, ..., F. In this case, the set of non-grouped attributes is empty; hence, the RELATION { ... } expression is TABLE_DEE.

If it joined the original relation with each original tuple, X would have no attributes, since COMPOSE removes common attributes.

> ie., each COMPOSE here produces a unique gB value
> because the two original rows have different B values and the result
> will have two rows after the projection.

No, the COMPOSE is an identity join, since one operand is TABLE_DEE. Thus X equals r, and is the same for every tuple in the result.

> In other words, when all
> attributes are grouped, the result has the same number of rows as the
> input.

No, the result has one tuple (unless the input is empty). All the X-es are the same, and all but X is projected away.

-- 
Jon
Received on Sun Jun 17 2007 - 11:10:05 CEST

Original text of this message