![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| ||||
| ||||
|
|
You may be turning things upside down. It is crystal clear that in a D (which does not expose internal details such as ROWID), individual tuples can only be identified using a (/the) key value. *Identifying that individual tuples in two distinct database states are about the same real-life object, is then only achievable if the key value hasn't changed. Trying to overcome this, e.g. by introducing some kind of "objectid" in the data which is "eternally, once and for all" linked to the tuple in question has other serious ramifications. * |
|
For example, I suspect that UPDATE can no longer be seen as a shorthand for some particular combination of DELETE-then-INSERT, precisely because of this additional objectid. |
|
Besides, transition constraints are, imo, nowhere near as useful as the literature sometimes makes them seem to be. *The examples I see of them are always of the ilk "salaries cannot decrease" and "married cannot change to single". *But what if "married" does indeed need to go back to "single" because it was the introduction of "married" itself that was wrong in the first place ? *What if salaries DO need to decrease because a zero too many had been typed ? *Sorry, you made this mistake and you can't correct it ? *Sorry, you'll have to keep paying this 10-times-too-big salary and go bankrupt or you'll have to fire your employee ? *Come on. |
|
Or "I assume there is some kind of other machinery in place that allows supervisors to do all necessary corrections" ? *So the model deliberately does not aim to offer support for _ALL POSSIBLE_ transitions ? *Come on. |
#4
| ||||||
| ||||||
|
|
On Sep 3, 9:41*am, Erwin <e.sm... (AT) myonline (DOT) be> wrote: Trying to overcome this, e.g. by introducing some kind of "objectid" in the data which is "eternally, once and for all" linked to the tuple in question has other serious ramifications. * I'm not suggesting the introduction of an objectid. *I don't think it's necessary to do that. For example, I suspect that UPDATE can no longer be seen as a shorthand for some particular combination of DELETE-then-INSERT, precisely because of this additional objectid. UPDATE is not the same as a combination of DELETE-then-INSERT, but not because of some objectid. |
|
There is a mapping from every tuple in a database to something in the microworld that is being modeled, |
|
I just don't think the mechanism they suggest is sound. |
|
I think the mechanism that Date and Darwen propose is not logically sound. *Successive values for a relvar hold during adjacent, but not overlapping, intervals in time. *What was the case before an assignment can't also be what is the case after (unless it's a null assignment, of course). *It is therefore illogical to compare what was the case before an assignment to what is the case after. |
|
From a logical standpoint, a database is in essence a statement that asserts what has up to now been the case. *A transition is a statement that asserts, given what had until now been the case, what is different and how it is different--that is, have things come into existence, have things ceased to exist, or if things appear different, what are the differences? *From what has until now been the case and what is now different, one can determine what is now the case. *One cannot always determine what is different from what had until now been the case and what is now the case, as is illustrated by the example in the original post that is the result of a multiple assignment. *Given just the before and after values, it can't be determined with certainty whether Transition Constraint #4 was violated. |
|
Since a transition is a statement just like a database is a statement, it should be possible to represent the transition as a set of relations, three for each relation in the database. *One could be adorned with a '-' postfix and would contain the result of DELETEs that target the corresponding relvar; one could have a '+' postfix and would contain the result of INSERTs; one could have a '~' postfix and would contain the result of UPDATEs, each tuple containing the before and after values for each attribute. |
#5
| |||
| |||
|
|
I'm wondering if it is even possible to define the transition constraints below in D using Date and Darwen's mechanism described in TTM. What follows is a typical relvar that is used to record labor activities performed by employees in a manufacturing facility. (I've taken liberties with the D syntax for brevity.) LABOR {EMP#, WO#, SEQ, M#, LBRTYPE, LBRDATE, TIMEON, TIMEOFF, ELAPSED, APPLIED, PRODUCED, REJECTED, STATUS}, KEY {EMP#, WO#, SEQ, M#, LBRTYPE, LBRDATE, TIMEON}, KEY {EMP#, WO#, SEQ, M#, LBRTYPE, LBRDATE, TIMEOFF} CONSTRAINT IS_EMPTY ( LABOR WHERE ( STATUS = ‘O’ AND ( TIMEON<> TIMEOFF OR ELAPSED<> 0 OR APPLIED<> 0.0 OR PRODUCED<> 0 OR REJECTED<> 0 ) ) ) EMP# identifies the employee who performed the activity. WO# identifies the work order to which the activity applies. SEQ is the sequence in the work order. M# identifies the machine on which the activity was performed. OP identifies the operation performed. LBRTYPE identifies the type of labor: S[etup], D[irect], R[ework]. LBRDATE identifies the date on which the labor activity was performed. Activities performed after midnight on a shift that starts before midnight are applied to the previous day. TIMEON and TIMEOFF are the times the labor activity began and ended respectively. Labor activities that are currently being performed have the same TIMEON and TIMEOFF. TIMEOFF can be less than TIMEON when an activity starts before and ends after midnight. ELAPSED is the elapsed working time in minutes. Working time does not include breaks or lunch. ELAPSED is always less than 1440 minutes. ELAPSED is zero when TIMEON and TIMEOFF are the same. APPLIED is the working time in hours that is to be applied to the work order. (This is not necessarily the same as ELAPSED/60. An employee may have been on more than one job at the same time, for example, monitoring several different machines at the same time.) Like ELAPSED, APPLIED is zero when TIMEON and TIMEOFF are the same. PRODUCED and REJECTED are the quantities of the part for which the work order was cut that were produced and rejected as a result of the labor activity. It is possible for these to be zero—there are operations that can take more than one shift to complete, or the activity may have begun late in the shift. These are also zero when TIMEON and TIMEOFF are the same. STATUS is one of O[pen], C[losed], or A[pproved]. STATUS is O[pen] for labor activities that are currently being performed; STATUS is C[losed] for activities that are no longer being performed; STATUS is A[pproved] for activities that have been approved by management. Here are four transition constraints that implement specific business rules. Transition constraint #1: STATUS can only transition from O[pen] to C[losed] or from C[losed] to A[pproved]. Closed activities cannot be reopened; instead, a new activity is opened. Labor activities can't be approved while they’re being performed. Transition constraint #2: Labor activities with STATUS A[pproved] cannot be INSERTed, UPDATEd or DELETEd. Approved labor activities cannot be INSERTed because they have to have been reviewed before they can be approved. They can't have been reviewed if they hadn't already been in the database with STATUS C[losed]. Labor activities that have been approved affect WIP (work in progress inventory); as a consequence, once an activity has been approved, it cannot be altered or eliminated. Corrections to offset activities approved in error are accomplished through auditable journal entries recorded somewhere else in the database. Transition constraint #3: When STATUS transitions from C[losed] to A[pproved], only STATUS transitions from C[losed] to A[pproved]. A labor activity that is being approved has to have been reviewed before it can be approved. That can't have happened if any component other than STATUS differs. Transition constraint #4: LBRDATE can't be different. The date that a labor activity was performed doesn't change. Is it possible to implement the above transition constraints using the mechanism described by Date and Darwen on page 220 of TTM, Third Edition, RM VERY STRONG SUGGESTION 4: TRANSITION CONSTRAINTS? In this section they suggest using a primed relvar name to refer to the corresponding relvar as it was prior to the update under consideration. The keys are compound, and it's possible for both keys to change. For example, Joe entered the wrong work order when he clocked onto labor. When he tried to clock off, the system couldn't find the work order, so the next day an entry showed up on his supervisor’s error log. The labor activity from yesterday remained open. After determining what actually occurred, the supervisor specifies the correct work order number along with the time off, the quantities produced and rejected, the elapsed time and the hours to be applied, setting STATUS to C[losed]. Before: {EMP#:22, WO#:2343, SEQ:12, M#:M3, LBRTYPE , LBRDATE:2010-06-30,TIMEON:0800, TIMEOFF:0800, ELAPSED:0, APPLIED:0.0, PRODUCED:0, REJECTED:0, STATUS:O} After: {EMP#:22, WO#:2334, SEQ:12, M#:M3, LBRTYPE , LBRDATE:2010-06-30,TIMEON:0800, TIMEOFF:1500, ELAPSED:330, APPLIED:5.5, PRODUCED:33, REJECTED:2, STATUS:C} The work order number is an element of both candidate keys, so both key values differ as a result of the supervisor's update. How would it be possible to match the tuple in the relvar as it was prior to the update under consideration to the tuple in the relvar as it would be after the update to verify that LBRDATE isn't different? Just in case you're tempted, you can't assume that the update under consideration involves only one tuple. There may have been a multiple assignment, and constraints are checked at statement boundaries--that is, after the entire multiple assignment, not between its component assignments. In this case, when the employee tried to log on today, an error occurred because he was already logged on, so the supervisor had to manually enter the activity. Before: {EMP#:22, WO#:2343, SEQ:12, M#:M3, LBRTYPE , LBRDATE:2010-06-30,TIMEON:0800, TIMEOFF:0800, ELAPSED:0, APPLIED:0.0, PRODUCED:0, REJECTED:0, STATUS:O} After: {EMP#:22, WO#:2334, SEQ:12, M#:M3, LBRTYPE , LBRDATE:2010-06-30,TIMEON:0800, TIMEOFF:1500, ELAPSED:330, APPLIED:5.5, PRODUCED:33, REJECTED:2, STATUS:C} {EMP#:22, WO#:2343, SEQ:12, M#:M3, LBRTYPE , LBRDATE:2010-07-01,TIMEON:0800, TIMEOFF:0800, ELAPSED:0, APPLIED:0.0, PRODUCED:0, REJECTED:0, STATUS:O} At first glance, this appears to be a clear violation of Transition Constraint #4 (Everything is identical except LBRDATE!), but it isn’t. The tuple with WO#:2343 before matches the tuple with WO#2334 after, and the tuple with WO#2343 represents a new labor activity that began on 2010-07-01. How can that be determined, given just the relvar as it was prior to the update under consideration and the relvar as it is after the update. |
#6
| |||||||||
| |||||||||
|
|
On 3 sep, 17:35, Brian <br... (AT) selzer-software (DOT) com> wrote: |
|
UPDATE is not the same as a combination of DELETE-then-INSERT, but not because of some objectid. It is the same. *Always. *Before some update, relvar R has value {t1}. *After that update, relvar R has the value {t2}. Please explain what the difference is between this update and a multiple assignment consisting of the delete of t1 and the insert of t2. |
|
My claim is furthermore supported by, e.g. (but not limited to) the UPDATE example in The Third Manifesto, page 154, and Date's treatment of view updating in Appendix E, in which he expresses all updates as consisting merely of an insert portion and a delete portion. *In the beginning of that Appendix, Date even provides actual proof to what I claim here ! |
|
There is a mapping from every tuple in a database to something in the microworld that is being modeled, There is no mapping. *A database is a collection of assertions of fact. *Insertions are assertions of fact that were previously not believed to be true, but now do, and deletions are assertions of fact that were indeed believed to be true, but no longer are. |
|
I just don't think the mechanism they suggest is sound. My recollection of The third Manifesto is that it only says an extremely minimal bit about "transition constraints". *I hesitate to call that minimal bit a "proposed mechanism", and certainly do not find the grounds on which to dismiss it as "logically unsound". *Maybe you can enlighten me with page references. |
|
I think the mechanism that Date and Darwen propose is not logically sound. *Successive values for a relvar hold during adjacent, but not overlapping, intervals in time. *What was the case before an assignment can't also be what is the case after (unless it's a null assignment, of course). *It is therefore illogical to compare what was the case before an assignment to what is the case after. Depends on what precise meaning you attach here to "compare". *Compare for equality (database equality) ? *Presumably not. A database variable has, at any moment in time, a database value D. Database updating is the process of replacing that value D with a new value D'. The "delta" between D and D' can be modeled as a tuple (called 'S' for Statement) holding all the deletions and all the insertions of all (base) relvars. The following equivalences hold: D' = D dbadd S */* dbadd is the operator that "applies S to D" */ D = D' dbundo S */* dbundo is the operator that "undoes an update" : instead of adding the insertions in S and removing the deletions in S, it adds the deletions in S and removes the insertions in S */ S = D' dbdelta D */* should be obvious */ |
|
From a logical standpoint, a database is in essence a statement that asserts what has up to now been the case. *A transition is a statement that asserts, given what had until now been the case, what is different and how it is different--that is, have things come into existence, have things ceased to exist, or if things appear different, what are the differences? *From what has until now been the case and what is now different, one can determine what is now the case. *One cannot always determine what is different from what had until now been the case and what is now the case, as is illustrated by the example in the original post that is the result of a multiple assignment. *Given just the before and after values, it can't be determined with certainty whether Transition Constraint #4 was violated. It can. *What isn't certain is that it will always produce the outcome you would want to see produced. |
|
What you then need to do is reformulate your transition constraints in such a way that they do. You can try out SIRA_PRISE if you want. *It supports declarative transition constraints (they're baptised differently, though, for reasons I documented in the new implementer's comments on TTM). |
|
Since a transition is a statement just like a database is a statement, it should be possible to represent the transition as a set of relations, three for each relation in the database. *One could be adorned with a '-' postfix and would contain the result of DELETEs that target the corresponding relvar; one could have a '+' postfix and would contain the result of INSERTs; one could have a '~' postfix and would contain the result of UPDATEs, each tuple containing the before and after values for each attribute. As I indicated with my D',D and S stuff : you have said nothing incorrect here, except that a statement is a set of TWO relations per relvar, not three.- Hide quoted text - - Show quoted text - |
#7
| |||
| |||
|
|
On Sep 3, 2:29 pm, Erwin <e.sm... (AT) myonline (DOT) be> wrote: On 3 sep, 17:35, Brian <br... (AT) selzer-software (DOT) com> wrote: snip UPDATE is not the same as a combination of DELETE-then-INSERT, but not because of some objectid. It is the same. Always. Before some update, relvar R has value {t1}. After that update, relvar R has the value {t2}. Please explain what the difference is between this update and a multiple assignment consisting of the delete of t1 and the insert of t2. In the update, the referent of t1 is the referent of t2, but in the multiple assignment, the referent of t1 ceased to exist and the referent of t2 came into existence. The "meaning" of the fact "t2" is therefore different. For example, |
#8
| ||||||||
| ||||||||
|
|
On Sep 3, 2:29*pm, Erwin <e.sm... (AT) myonline (DOT) be> wrote: On 3 sep, 17:35, Brian <br... (AT) selzer-software (DOT) com> wrote: snip Please explain what the difference is between this update and a multiple assignment consisting of the delete of t1 and the insert of t2. In the update, the referent of t1 is the referent of t2, but in the multiple assignment, the referent of t1 ceased to exist and the referent of t2 came into existence. *The "meaning" of the fact "t2" is therefore different. *For example, |
|
before: The person at the front of the line is wearing a red hat. after: The person at the front of the line is wearing a blue hat. Did the person who has up to now been at the front of the line don a blue hat, or has the person who has until now been at the front of the line been replaced by someone else? |
|
Date oversimplifies. |
|
There is a mapping from every tuple in a database to something in the microworld that is being modeled, There is no mapping. *A database is a collection of assertions of fact. *Insertions are assertions of fact that were previously not believed to be true, but now do, and deletions are assertions of fact that were indeed believed to be true, but no longer are. There is definitely a mapping. *In his book, Codd wrote, "keys in the relational model act as surrogates for the objects being modeled." *(Page 25) *By definition, every relation has at least one candidate key, so every tuple has at least one key, and therefore every tuple maps to something in the microworld that is being modeled. |
|
I just don't think the mechanism they suggest is sound. My recollection of The third Manifesto is that it only says an extremely minimal bit about "transition constraints". *I hesitate to call that minimal bit a "proposed mechanism", and certainly do not find the grounds on which to dismiss it as "logically unsound". *Maybe you can enlighten me with page references. Page 220-221. |
|
I think the mechanism that Date and Darwen propose is not logically sound. *Successive values for a relvar hold during adjacent, but not overlapping, intervals in time. *What was the case before an assignment can't also be what is the case after (unless it's a null assignment, of course). *It is therefore illogical to compare what was the case before an assignment to what is the case after. Depends on what precise meaning you attach here to "compare". *Compare for equality (database equality) ? *Presumably not. A database variable has, at any moment in time, a database value D. Database updating is the process of replacing that value D with a new value D'. The "delta" between D and D' can be modeled as a tuple (called 'S' for Statement) holding all the deletions and all the insertions of all (base) relvars. The following equivalences hold: D' = D dbadd S */* dbadd is the operator that "applies S to D" */ D = D' dbundo S */* dbundo is the operator that "undoes an update" : instead of adding the insertions in S and removing the deletions in S, it adds the deletions in S and removes the insertions in S */ S = D' dbdelta D */* should be obvious */ You are committing the same oversimplification as Date. |
|
The objects that are the referents of the facts represented in a database are concrete: they have a location in time if not also space. *They are not abstract mathematical objects which are independent of time, and it is a mistake to treat them as such. *Concrete objects can come into existence, they can cease to exist, and they can differ in appearance at different times during their lifetime. |
|
From a logical standpoint, a database is in essence a statement that asserts what has up to now been the case. *A transition is a statement that asserts, given what had until now been the case, what is different and how it is different--that is, have things come into existence, have things ceased to exist, or if things appear different, what are the differences? *From what has until now been the case and what is now different, one can determine what is now the case. *One cannot always determine what is different from what had until now been the case and what is now the case, as is illustrated by the example in the original post that is the result of a multiple assignment. *Given just the before and after values, it can't be determined with certainty whether Transition Constraint #4 was violated. It can. *What isn't certain is that it will always produce the outcome you would want to see produced. Please enlighten me: how can it be determined which tuple in the after value matches the tuple in the before value? |
#9
| |||
| |||
|
|
That is not entirely untrue, because of the CWA. *A tuple represents a proposition that is believed to be true in the microworld modeled by the database in which the tuple appears. *Applying the CWA to determine whether some tuple should or should not appear in the database, cannot possibly be done by the DBMS, and is therefore the exclusive responsibility of the user. *So while such a mapping can indeed be perceived to exist, it is by definition of no use to the DBMS and it is therefore a mistake to let the DBMS be bothered with such mapping. |
#10
| |||
| |||
|
|
On 4 sep, 05:21, Brian <br... (AT) selzer-software (DOT) com> wrote: On Sep 3, 2:29*pm, Erwin <e.sm... (AT) myonline (DOT) be> wrote: On 3 sep, 17:35, Brian <br... (AT) selzer-software (DOT) com> wrote: snip Please explain what the difference is between this update and a multiple assignment consisting of the delete of t1 and the insert of t2. In the update, the referent of t1 is the referent of t2, but in the multiple assignment, the referent of t1 ceased to exist and the referent of t2 came into existence. *The "meaning" of the fact "t2" is therefore different. *For example, So the meaning of t2 does not depend exclusively on the attribute values within it, but also on its history of how it came into existence ? The fact documented by a tuple t2 in a relvar R is nothing more and nothing less than the instantiation of the relvar's external predicate with the attribute values of t2. *You claim to the contrary, that it also includes "something" to do with the history of how t2 came to be. |
|
You are free to think as you like. *But my position (which is also Date's) allows me to use the CWA, and the CWA alone, to determine whether or not some tuple should or should not appear in some relvar. |
![]() |
| Thread Tools | |
| Display Modes | |
| |