1

Transactions are said to need both atomicity and consistency. But, what is the point of consistency?

Once you ensure that you either update both accounts on money transfer, you are consistent. Wikipedia article on consistency says that consistency is a set of programmatic constraints, invariants. But you are free to code your transaction operations any way. So, I feel that programmer only needs Atomicity, Isolation and Durability. Consistency is an additional convenience DB tool, like trigger or stored procedure and is not absolute low level requirement. Given AID, the programmer can always ensure the consistency. It is a simple as check user data and reject the request if some rule is broken. Right?

It looks like Wikipedia identifies Atomicity with Consistency in the Data Consistency article, but not in the article on ACID transactions.

Listening on eventual consistency, I see that developers mean that DB is always in some correct snapshot state, i.e. data are stabilized and you can query/issue your transaction upon the DB, which you could not do if DB is available in transition. That is, consistent DB is one which satisfies the constraints at any moment of time. But, it satisifies the constraints if operations are atomic. Atomicity implies that we see only transaction results, which implies that we see only snapshots, which means consistence. Why do you need to single the consistence out as if it is independent property?

  • Transactions need to be both atomic and consist. But, why we need consistency?.. Imagine you are developer of a bank application and suppose your database is not consistent ,but 100% atomic(all or none).you might have a rule assuming Daily withdrawal balance is 100K.User withdraws money and the transaction is either successfull or failure(Atomic).But what if the same transaction violates your business rule ,there by allowing the user to withdraw more than allowed limit.Does this qualify as a successfull transaction ?. – TheGameiswar Mar 11 '16 at 14:43
  • It should not be,the database should be left in consistent state even after the transaction is complete as per consistency rule and if it violates this ,the transaction fails – TheGameiswar Mar 11 '16 at 14:43
  • @TheGameiswar Ok, you seem to say that the point is not only that I am ensured that I always find my DB in stable state (a snapshot) but the that all transitions from one snapshot to another, called 'transactions', are also legal. – Valentin Tihomirov Mar 11 '16 at 14:51
0

This is how I got it. You can end up in an inconsistent database if user can see partially applied transaction (atomicity violated). But the same corrupted view can also result if the transaction itself is crazy and fails to include all the actions, which are supposed to be done atomically. So, given atomicity, we can indeed always achieve the consistent views/snaphots of the database. But, DB users prefer to deal with databases which enable restricting the state transitions to only legal state transition. So, atomicity ensures that DB user works with stable states whereas consistency ensures that only valid state transitions can take place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.