Re: globals besides relvars?

From: Marshall Spight <mspight_at_dnai.com>
Date: Mon, 28 Jul 2003 16:16:51 GMT
Message-ID: <S%bVa.149598$wk6.37711_at_rwcrnsc52.ops.asp.att.net>


"Paul Vernon" <paul.vernon_at_ukk.ibmm.comm> wrote in message news:bg373c$16i2$1_at_gazette.almaden.ibm.com...
> "Marshall Spight" <mspight_at_dnai.com> wrote in message
> news:eX0Va.143552$GL4.37155_at_rwcrnsc53...
>
> > So what if you have some function that requires some storage?
>
> No such thing. Functions take values, do some computation on those values, and return
> some other values. They don't store values (at least not ones that change), that is
> what assignment is for.

This is true for functions in the strict mathematical sense, but in most programming languages, functions have access to global data. In many programming languages, functions have access to function-local state as well.

> > For example, imagine a function that returns the current timezone.
> > It needs to store this somewhere.
>
> current timezone is not a function. It is just a value of some relvar.

"A function" is a perfectly good name for "a value of some relvar." (Well, a part of a relvar, anyway.) It more typically refers to some code, but the above still works.

> Same goes for all of the SQL 'special registers'. By which I mean, in a truly
> relational dbms, there would not be any special registers, or functions that store
> values. Such things would violate the information principle
>
> IMO A good catalog model would include relvars to holds things like current timestamp
> and current USER.

Okay, but why do these things have to be relvars? I mean, the current timezone is not a relation, it's a value from the timezone domain. Current user is a string or a User value or something. It's not a relation. So why must it go into a relation? I'm already aware that Codd so asserted, but I don't see any good theoretical or even a good design reason for it.

Worse, if I make a relvar Timezone, I can issue nonsensical updates to it. What does it mean to insert into Timezone? Okay, so maybe you say the fact that I have a no-columns key for the table makes that insert fail. Or there's some kind of constraint that prevents a delete from succeeding. But it would be better if the structure made it the case that these nonsensical updates weren't even expressible. That's what you get if you make Timezone a global *non-relation* variable.

> > Earlier I was thinking about operator identity. (The + operator
> > has zero as the identity value; multiply has 1.) This seems
> > like it associates with a function as well. But this idea doesn't
> > seem so problematic, because it's just a constant.
>
> something as simple as this
>
> SELECT * FROM FUNCTION_LITERAL
> WHERE IN_VALUE = OUT_VALUE
>
> would return you all the identity mappings of a function

Um, that's not the same thing. It's not even clear what the above means for a binary operator. In any event, the above might require infinite time to return.

I'm talking about the fact that some functions (in the pure mathematical sense) have associated "identity" values. That is, for all x, there exists a value id such that x op id = x.

It makes sense to me to consider this constant value as being visible in some places. There are advantages to being able to query the op to see if it has an identity, and what the value is.

Marshall Received on Mon Jul 28 2003 - 18:16:51 CEST

Original text of this message