This document discusses integrity enforcement in distributed database systems. It describes two basic methods for rejecting inconsistent update transactions: detection and prevention. Detection involves executing an update and checking if it violates integrity constraints, then compensating or undoing the update if needed. Prevention involves checking integrity constraints before executing an update to prevent violations. The document provides examples of posttests and pretests used to check constraints after and before state changes. It also describes a query modification algorithm that modifies queries to include integrity constraint checks to enforce constraints preventively at runtime.
4. INTEGRITY ENFORCEMENT
Semantic integrity consists of rejecting update
transactions that violate some integrity
constraints.
Integrity constraints represent knowledge about
data with which a database must be
consistent, which means that the data
contained in a database is both accurate and
valid.
A constraint is violated when it becomes false in
the new database state produced by the
update transaction.
5. METHODS
Two basic methods permit the rejection of
inconsistent update transactions.
Detection
Prevention
6. 1. DETECTION
The first one is based on the detection of
inconsistencies.
Execute update u: D Du
If Du is inconsistent then
if possible: compensate Du Du
’
else
undo Du D
This approach may be inefficient if a large
amount of work (the update of D) must be
undone in the case of an integrity failure.
7. 2. PREVENTION
The second method is based on the prevention
of inconsistencies. An update is executed only
if it changes the database state to a consistent
state.
Execute u: D Du only if Du will be consistent
The tuples subject to the update transaction are
either
directly available (in the case of insert) or
must be retrieved from the database (in the
case of deletion or modification)
8. EFFICIENCY
The preventive approach is more efficient than
the detection approach since updates never
need to be undone because of integrity
violation.
9. POSTTEST & PRETEST
POSTTEST
Tests are derived by
integrity constraints.
these tests are
applied after having
changed the
database state, they
are generally called
posttests.
PRETEST
Tests, derived by
integrity constraints,
are applied before
the database state
is changed they are
generally called
pretests.
10. QUERY MODIFICATION ALGO
The query modification algorithm is an
example of a preventive method that is
particularly efficient at enforcing domain
constraints.
It adds the assertion qualification to the query
qualification by an AND operator so that the
modified query can enforce integrity.
11. EXAMPLE
UPDATE PROJ
SET BUDGET = BUDGET*1.1
WHERE PNAME = "CAD/CAM"
UPDATE PROJ
SET BUDGET = BUDGET*1.1
WHERE PNAME = "CAD/CAM"
AND NEW.BUDGET ≥ 500000
AND NEW.BUDGET ≤ 1000000
12. QUERY MODIFICATION ALGO
It produces pretests at run time by ANDing
the assertion predicates with the update
predicates of each instruction of the
transaction.
This algorithm only applies to tuple calculus
formulae
Editor's Notes
The update transaction u is executed, causing a change of the database state D to Du. The enforcement algorithm verifies, by applying tests derived from these constraints, that all relevant constraints hold in state Du. If state Du is inconsistent, the DBMS can try either to reach another consistent state,
D’u by modifying Du with compensation actions, or to restore state D by undoing u.