Database Reference
In-Depth Information
234
FIGURE 7-5
Elena updates the database
In the preceding sequence of updates, everything worked out correctly, but this is not always the case. Do
you see how the updates to the database could occur in a way that would lead to an incorrect result?
What if the updates occur in the sequence shown in Figure 7-6 instead? First, the DBMS reads the data
from the database into Ryan
'
s work area in memory. At about the same time, the DBMS reads the data from
the database into Elena
s separate work area in memory. At this point, both Ryan and Elena have the correct
data for Brookings Direct, including a balance of $431.50. Ryan adds $100.00 to the balance in his work area,
and Elena subtracts $100.00 from the balance in her work area. At this point, in Ryan
'
'
s work area in memory
the balance is $531.50, while in Elena
'
s work area in memory, the balance is $331.50. The DBMS now
updates the database with Ryan
s change. At this moment, Brookings Direct has a balance of $531.50 in the
database. Finally, the DBMS updates the database with Elena
'
s. Now the
balance for Brookings Direct in the database is $331.50! Had the DBMS updated the database in the reverse
order, the final balance would have been $531.50. In either case, you would now have incorrect data in the
database
'
s change. Her update replaces Ryan
'
one of the updates has been lost. The DBMS must prevent these lost updates from affecting the
database.
Search WWH ::




Custom Search