| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: constraints in algebra instead of calculus
Jon Heggland wrote:
> Jan Hidders wrote:
>
>>Assume R = { (A:1, B:2), (A:1, B:3) }
>>
>>R{B} = { (B:2}, (B:3) }
>>R1 = R{B} GROUP {B} AS gB = { (gB:{ (B:2} }), (gB:{ (B:3) }) }
>>(R GROUP {B} AS gB) = { (A:1, gB:{ (B:2}, (B:3) }) }
>>R2 = (R GROUP {B} AS gB){gB} = { (gB:{ (B:2}, (B:3) }) }
I'm weak when it comes to TTM notation but I think Jan H was following TTM as I read it. I find it easier to draw a bastardized form of table and drop either the introduced name or a single original name:
R:
A B 1 2 1 3
R{B} GROUP {B} as gB:
gB
{2}
{3}
where it is understood that the braces indicate a set, so the result has two rows.
I think you are suggesting:
R GROUP {B} as gB:
gB
{2,3}
where the result has one row.
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, 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. In other words, when all attributes are grouped, the result has the same number of rows as the input.
Whereas
R GROUP {B} as gB:
A B
1 {2,3}
has only one row because the COMPOSE matches on the A value of both original rows
If this is right, Jan H's expression seems to hit the nail exactly on the head because the GROUP result includes a row with a non-singleton set of B values only when the non-grouped attributes couldn't be a superkey/candidate key and vice versa. (But I don't know why the "superkey" term is necessary in the context of testing a value for the constraint Marshall S asked about, also I think he wasn't looking for the kind of plumbing that WRAP would need.)
p Received on Sat Jun 16 2007 - 11:33:02 CDT
![]() |
![]() |