Databases Reference
In-Depth Information
successfully. That is, you don't expect the teller to accept your money and then go to lunch, forget-
ting to credit your account. That kind of behavior would obviously ruin a bank; and when we revisit
atomicity in the context of the database, you'll see that it would also ruin a database.
C Is for Consistent
Consistent means that everything is in agreement — in this case, the amount deposited is the
amount credited. If you access a list of your recent transactions, the $50 that you deposited on
Monday must be recorded as $50 on Monday, not $48 on Monday, not $52 on Tuesday, or any
other combination of incorrect data. In other words, it is imperative that your records match the
bank's records. Although you may feel personally slighted or ignored at the bank, or the teller may
not remember you between visits, you need to feel coni dent that the bank can successfully process
your transactions such that they are completed in a consistent manner.
I Is for Isolated
Banks understand discretion. If you are going through your dealings with a teller, you don't expect
someone to be listening to the conversation and potentially making decisions based on what's going
on. Isolation is the protection provided around the visibility of what's going on during each stage of
the transaction, and extends out to whether your transaction can be affected by anything else that
might be going on at the same time. Importantly, there are different levels of isolation that can be
chosen.
For example, if your spouse is in another branch making a separate transaction, you might be okay
with that branch seeing some information about your transaction part way through it, but you
almost certainly wouldn't want to see a bank statement issued that only gave half the story.
D Is for Durable
Durability rel ects the fact that your bank transaction cannot be accidentally deleted or otherwise
compromised. After you deposit your money and receive a receipt, you are assured that your money
is safe and available to you. Even in the event of system failure, the record of the fact that you
deposited money should persist, no matter what happens next.
DATABASE TR ANSACTIONS
Having looked at the ACID principles in the context of a bank transaction in the preceding section,
this section examines how these four principles relate to your database environment, which you
need to protect with just as much care as the bank affords to your monetary transactions.
Atomicity
When you make a change in the database that involves multiple operations, such as modifying two
separate tables, if you have identii ed these operations as a single transaction, then you expect an
all-or-nothing result — that is, the change is completely atomic. Recall from the bank analogy that
depositing $50 must result in an additional $50 in your account. If the bank's server freezes or the
 
Search WWH ::




Custom Search