Board index » delphi » Example of inconsistent data state with OPF
Example of inconsistent data state with OPF
2005-11-01 03:33:19 PM
Jim Cooper writes:
you /disputed/ the need for two separate processes to achieve the
Oh no, two lines of code!!
"update" with an OPF. When I clearly demonstrated to you of the
existence of such a situation, you begin to exclaim that two lines of
code are no big deal. :(
It is quite possible that you /really/ don't understand the /impact/ of
the two-step process of achieving the update.
Let me explain again, with some examples.
The best way to show this is to use XML representation of the classes
in the OPF scenario:
So, this is your typical containment scenario (BOClass contains a list
of DetailClasses). Great.
Now suppose you want to associate DetailClass6 with BOClass1. In an
OPF scenario, you will have to achieve this with TWO distinct steps:
1. Remove DetailClass6 as a child node of BOClass2; then
2. Insert DetailClass6 as a child node of BOClass2;
If 1. succeeds but 2. fails, you have inconsistent data state requiring
explicit management to recover from! (The very idea we pay such huge
amounts of money for RDBM technology. <g>) This is how the data could
look in an inconsistent state:
<-- missing data!!!!
However, in a DataSet scenario, the following is the situation:
DetailClass6|BOClass2|x <-- Update this only. (One step).
(The above BOClass_DataSet remains untouched.)
So, to recap: what have we done with the dataset scenario? We have
simply /borrowed/ the good work of sound data modeling techniques from
our database so that data consistency can be maintained in our
"process" tiers too. Fantastic!
>Clearly that there are two distinct steps involved here:
>Now suppose that 1) succeeds and 2) fails? What happens to our
>Isn't it /inconsitent/?
recovering from such a state? No doubt, you will have to introduce
Of course, you can always
pseudo-transactional semantics or some sort of compensating transactions
in order to keep your in-memory state consistent!
An in-memory normalised dataset would avoid this completely, because it
would not entertain the OO ideas of containment or inheritance. Like
properly designed data models, datasets can take advantage of the exact
same modeling consistency to their advantage!
could result in inconsistent data in memory. We've proved it. /That/
>That's the point.
is the point.