Re: thinking about UPDATE

From: Jan Hidders <jan.hidders_at_REMOVETHIS.pandora.be>
Date: Wed, 21 Jul 2004 10:02:57 GMT
Message-Id: <pan.2004.07.21.10.03.40.447528_at_REMOVETHIS.pandora.be>


On Wed, 21 Jul 2004 04:10:22 +0000, Marshall Spight wrote:
>
> But what the heck is UPDATE?
>
> If T : {a1, a2, ... an}
>
> UPDATE T set a1 = 0 where <cond>
> is
> T' = T { 0, a2, ... an | <cond> }
> T = T - T { a1, a2, ... an | <cond> }
> T = T union T'
>
> That's certainly more complicated than I would suspect
> for what seems like such a simple operation.
>
> Am I making it needlessly complex, or is this about right?
> Is there some other way to think about UPDATE?

Yes. You can think of your update as (1) a condition C(t) for a tuple t and (2) a function F(t) that maps an old tuple to a new tuple. For example, in your case F(t) is defined by F((a1, a2, ..., an)) = (0, a2, ..., an). And then you can write the update as

  T := { F(t) | t in T and C(t) } union { t | t in T and not(C(t)) }

which is equivalent with what you wrote. But if you define a function F'(t) such that

  F'(t) = F(t) if C(t)
  F'(t) = t if not C(t)

then you get:

  T := { F'(t) | t in T }

  • Jan Hidders
Received on Wed Jul 21 2004 - 12:02:57 CEST

Original text of this message