edited by
14,124 views
33 votes
33 votes

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
edited by

4 Answers

Best answer
30 votes
30 votes
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.
selected by
18 votes
18 votes

Answer (B)

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.

Answer source.

11 votes
11 votes
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.
Answer:

Related questions

16 votes
16 votes
2 answers
2
go_editor asked Feb 12, 2015
2,788 views
We __________ our friends's birthday and we _________ how to make it up to him.completely forgot - don't just knowforgot completely - don't just knowcompletely forgot ...