Re: thinking about UPDATE

From: Marshall Spight <mspight_at_dnai.com>
Date: Wed, 21 Jul 2004 16:46:44 GMT
Message-ID: <U5xLc.136544$%_6.64290_at_attbi_s01>


"Jan Hidders" <jan.hidders_at_REMOVETHIS.pandora.be> wrote in message news: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 }

D'oh! That's so clearly better I feel like a buffon for not seeing it.

I note F' has type a1 ... an -> a1 ... an, or more generally S -> S where T : {S}. I guess C would be called the characteristic function of the update set, yes?

Now I'll try to extrapolate from there to think about INSERT OR UPDATE. I suspect the key lies in generalizing type of the map function F' from S -> S to S -> {S}, or something similar.

Marshall Received on Wed Jul 21 2004 - 18:46:44 CEST

Original text of this message