What is ACID in database?

7

I'm not talking about web implementation indicator .

Beyond the acronym, why is it important?

    
asked by anonymous 11.05.2017 / 14:41

1 answer

6
  • Atomicity

    It's something indivisible. Or whatever is in a transaction must be successfully performed, or nothing should be accomplished. At least nothing should be considered as accomplished. Without the atomicity it becomes difficult if not impossible to keep the other characteristics, so the transaction is important.

  • Consistency

    The database must have a finished transaction in a consistent state, ie it must respect all the rules imposed on the database for all those involved in the transaction.

  • Isolation

    One transaction can not interfere with another while it is in business. Only after its completion will your result be available for other transactions.

  • Durability

    At the end of the transaction, the result should remain in the database, no matter what happens.

Motivation

Without these characteristics, the database is unreliable. An operation may end in half, or it may be in a state that will cause problems, or manipulate data that is not yet known to be useful or final or may still lose what has been done.

Some databases say ACID when they are actually almost ACID :) They are ACID, but not much , there are some cases that they do not guarantee this, ie they say they are over or less pregnant:)

The concept is implemented to avoid race conditions and similar problems. In link you have an example bank account that is the classic problem.

  • If you need to update the balance of an account you need to ensure that everything that is done to change the balance must be carried through to the end, can not change in one table and not change in another, can not debit in one account and fail to debit in another (atomicity).

  • At the end of the transaction you can not leave the balance with a value that has been determined that is not allowed, for example: normal balance plus limit is negative, or the balance does not have an operation linked to it (consistency).

  • You can not let other transactions view the credit until it is complete, as the transaction may not work, or it may also have other credits or debits that will affect the end result (isolation).

  • p>
  • You can not keep the new balance amount and everything that was done to reach it (durability).

This is usually achieved by a journaling system, write ahead log or some similar form. It is important that transaction transactions are made outside the normal database access and only enter its end. The most commonly used techniques are two phase locking , multi version concurrency control and snapshot isolation .

Wikipedia article .

The so-called NoSQL databases are not usually ACID (some are up, some are partially, ie they are not). Those that are do not offer all those advantages that say NoSQL has, there is no miracle. Or they are not trustworthy. Of course problems that overall performance and distribution are more important than information reliability so it is useful. Just as you have problems like this, ACID databases may perform better in certain scenarios.

If you do not know what you're doing, NoSQL can be tragic and much slower.

    
11.05.2017 / 14:41