Databases Reference
In-Depth Information
Figure 10-7
Transaction
T1
Read TextBookInventory 100-500
Calculate row changes
Read each row
Process row and modify values
Commit transaction
Warehouse Database
Transaction
T2
Delete 200
Commit transaction
TextBookInventory
100 Chemistry
120 Physics
131 Physical Science
200 Social Studies
310 Inro. To Literature
Customer
1001 Northgate
1040 Westview
1910 Eastland
Phantom read example.
In this example, T1 reads selected columns from the TextBookInventory table
to determine if they meet a set of criteria for further processing. In this exam-
ple, the criteria include the suggested order point and the quantity on hand.
When it determines which rows meet the criteria, it goes back and reads selected
rows from the table, this time extracting all columns, before making updates. In
the interim, T2 has made changes to rows in TextBookInventory. When T1 reads
the rows a second time, it might discover that items 120 and 200 no longer
qualify, resulting in an error.
The last error type is the phantom read error. This happens when
a transaction reads a range of rows, but when it goes back to read the same
rows again, either one or more are missing or rows have been added. The
missing rows or added rows are referred to as phantoms. Take a look at
Figure 10-7.
In Figure 10-7, T1 reads a range of rows from TextBookInventory. It calcu-
lates changes to be made to the rows. While it is making those calculations, T2
deletes one of the rows. As a way of helping to ensure data integrity, T1 goes
back and reads each row again before writing the changes. When it does, it will
discover that one of the rows is a phantom—it no longer exists.
Search WWH ::




Custom Search