8,735 views

Consider the following transaction involving two bank accounts $x$ and $y$.

  read(x); x:=x-50; write (x); read(y); y:=y+50; write(y)

The constraint that the sum of the accounts $x$ and $y$ should remain constant is that of

1. Atomicity
2. Consistency
3. Isolation
4. Durability

shots fired, shots fired.

There is nothing to do with given transaction it is just for confusing since it is application dependent constraints (i.e Explicit constraints) for which consistancy of database is responsible.

B. Consistency

In the given transaction Atomicity guarantees that the said constraint is satisfied. But this constraint is not part of Atomicity property. It is just that Atomicity implies Consistency here.
by

Yes, exactly. A calm mind gets a lot of mark in GATE :)
@Arjun sir. Suppose the answer is Isolation to the modified version of this problem. Can you please help what can be the modified version?This will clear some doubt.

Hi All,

Why can't we go with option durability?

As per question The sum of account x and y should remain constant .

So even if there is some failure the values should not change and final values should be retained. So I beleive answer might be durability.

Some one please correct me if my understanding is wrong.

## Explaination:

Transaction to transfer $50 from account A to account B: 1. read(A); 2. A:=A-50; 3. write(A); 4. read(B); 5. B:=B+50; 6. write(B); • Atomicity requirement • if the transaction fails after step 3 and before step 6, money will be “lost” leading to an inconsistent database state. • Failure could be due to software or hardware. • the system should ensure that updates of a partially executed transaction are not reflected in the database. • Durability requirement • once the user has been notified that the transaction has completed (i.e., the transfer of the$50 has taken place), the updates to the database by the transaction must persist even if there are software or hardware failures.

• Consistency requirement

• (in above example) the sum of A and B is unchanged by the execution of the transaction.

• In general, consistency requirements include

• Explicitly specified integrity constraints such as primary keys and foreign keys.

• Implicit integrity constraints- e.g. sum of balances of all accounts, minus sum of loan amounts must equal value of cash­ in­ hand.

• A transaction must see a consistent database.

• During transaction execution the database may be temporarily inconsistent.

• When the transaction completes successfully the database must be consistent.

• Erroneous transaction logic can lead to inconsistency

• Isolation requirement

• if between steps 3 and 6, another transaction T2 is allowed to access the partially updated database, it will see an inconsistent database (the sum A + B will be less than it should be).

• Isolation can be ensured trivially by running transactions serially.

### 1 comment

This should be the marked answer
Kindly check out PPT for Transaction chapter in below link.( Part 5: Transaction Management Ch. 15)

http://www.cse.iitb.ac.in/~sudarsha/db-book/slide-dir/

Question is directly taken from Korth. And wording almost completely matches to Consistency requirement.

@Lakshman Patel RJIT sir plz update the link as it’s not working

Consistency so option b