Re: a sort-of key question

From: Jan Hidders <jan.hidders_at_REMOVETHIS.pandora.be>
Date: Sun, 20 Mar 2005 00:28:42 GMT
Message-ID: <_s3%d.41531$UB2.3691629_at_phobos.telenet-ops.be>


paul c wrote:
> Looking at Darwen and Date's Third Manifesto, chapter four and
> re-examining the fundamental operations that seem possible within the
> relational model (to the extent that there is any common agreement about
> what that is) I wonder how to answer the following question:
>
> What are the last names of the people who share a last name with
> somebody else?
>
> Suppose the relation R is this:
>
> LAST FIRST
> _____ _____
> Smith Billy
> Smith Bobby
> Jones Nathan
>
> I'd expect the answer to be {Smith}.

Let the relation be R(Last,First)

S := RENAME[First->First2](R)
T := R JOIN S                          // JOIN = the natural join
U := SELECT[First<>First2](T)
V := PROJECT[Last](U)

  • Jan Hidders
Received on Sun Mar 20 2005 - 01:28:42 CET

Original text of this message