Department of Software Engineering Advanced Database Individual Assignment
Department of Software Engineering Advanced Database Individual Assignment
ENGINEERING
ADVANCED DATABASE
INDIVIDUAL ASSIGNMENT
T1 T2
read_item(X);
X:=X-N;
write_item(X);
read_item(X);
X:=X+M;
write_item(X);
read_item(Y);
N.B Transaction T1 fails and must change the value of X back to
its old value; meanwhile T2 has read the temporary incorrect value
of X.
3. The Incorrect Summary Problem- If one transaction is
calculating an aggregate summary function on a number of
database items while other transactions are updating some of these
items, the aggregate function may calculate some values before
they are updated and others after they are updated. For example,
suppose that a transaction T3 is calculating the total number of
reservations on all the flights; meanwhile, transaction T1 is
executing. If the interleaving of operations shown in Figure 2.4
occurs, the result of T3 will be off by an amount N because T3
reads the value of X after N seats have been subtracted from it but
reads the value of Y before those N seats have been added to it.
Fig 2.4 Incorrect summary problem
T1 T3
sum:=0;
read_item(A);
sum:=sum+A;
read_item(X);
X:=X-N;
write_item(X);
read_item(X);
sum:=sum+X;
read_item(Y);
sum:=sum+Y;
read_item(Y);
Y:=Y+N;
write_item(Y);