Chapter 7. SQL Remote Design for AdaptiveSer verAnywhere
Resolving inventoryconflicts
Considera warehouse system for a manufacturer of sporting goods. Thereis
atable of product information, with a quantity column holding the number
ofeach product left in stock. Anupdate to this column will typically deplete
thequantity in stock or, if a new shipment is brought in, add to it.
Asales representative at a remote database enters an order, depleting the
stockof small tank top tee shirts by five, from 28 to 23, and enters this in on
herdatabase. Meanwhile,before this update is replicated to the consolidated
database,a new shipment of tee shirts comes in, and the warehouse enters
theshipment, adding 40 to the quantity column to make it 68.
28 > 6828 > 23
28 > 68
Updates
made at
remote
databases
Thewarehouse entry gets added to the database: thequantity column now
showsthere are 68 small tank-top tee shirts in stock. Whenthe update from
thesales representative arrives, it causes a conflict–Adaptive Server
Anywheredetects that the update is from 28 to 23, but that the current value
ofthe column is 68.
Bydefault, the most recent UPDATE succeeds, and the inventory levelis set
tothe incorrect value of 23.
28 > 6828 > 23
68 > 23
Default
conflict
resolution:
wrong result
Inthis case the conflict should be resolved by summing the changes to the
125