Re: relationship in the database
Date: Thu, 26 Sep 2002 12:13:33 +0100
Message-ID: <amuqai$de0$1_at_sp15at20.hursley.ibm.com>
>> No, the consequence is that some assignments are recognized as a single
>> tuple update.
>This is an unwanted and unwarranted limitations.
Agreed
>For a (very practical
>example) I have phone numbers in a country comprising of ten digits.
>Of course, the phone number is the natural key for the "phone line" (or
>whatever is the proper denomination), and I'd argue that no other key is
>really necessary, so we can imagine that a phoen number is foreign key
>in _lots_ of places.
>Then a need is recognized to have 11 digits in order to make room for
>more numbers. The existing numbers will be recognized by prefixing them
>with, let's say, the digit "5". Quite easy, right ?
>UPDATE ........ SET number= '5' || number.
>No big deal so far, the changes *should* be propagated in all places.
>Relational assignment doesn't support this. Therefore, I couldn't care
>less if (some) relational model is well defined and consistent and sound
>with only relational assignment as the one and only mean to change the
>database state.
Single relvar assignment indeed does not support the above.
The two traditional (i.e. SQL) answers have been:
a). Transactions. With constraint checking deferred to the finial COMMIT b). Referential actions attached to foreign keys. Including an implicit tuple-level update semantics for ON UPDATE CASCADE
On a), I see transactions as orthogonal to the model, and in fact would
argue that they are a bad idea to expose them at the logical level, but
that is a discussion for another day.
On b). This is obviously an ad-hoc solution that can only cover some cases
(i.e. those with FKs), irrespective of the implicit tuple assumption
Now the problem just becomes one of convenience.
which would perform the first multiple assignment
and for the second update we would get
WITH ( T1 ) AS old{old_A, old_B},
( EXTEND old ADD ( old_A + 2 AS A, old_B as B) ) as upd, ( upd { ALL BUT old_A, old_B } as new: T1 := ( T1 MINUS old ) UNION new ,T2 := ( T2 JOIN old ON A = old_A ) {old.A as A, T2.B}
which would perform the second multiple assignment
So if you want the convenience of SQL style referential actions in the RM, all we need do is realise that they need to be considered while an UPDATE is been translated into a relational assignment.
Sorted.
Regards
Paul Vernon
Business Intelligence, IBM Global Services
Received on Thu Sep 26 2002 - 13:13:33 CEST