ACID: Four essential elements for database transactions to execute correctly

Source: Internet
Author: User

ACID, which is an abbreviation for the four basic elements that the database transaction performs correctly. Contains: atomicity (atomicity), consistency (consistency), isolation (isolation), persistence (durability). A support transaction (Transaction) database, must have these four characteristics, otherwise in the transaction process (Transaction processing) can not guarantee the correctness of the data, the transaction process is very likely not to reach the requirements of the counterparty.

Atomic Nature
All operations in the entire transaction, either complete or incomplete, are not likely to stall in one part of the middle. When an error occurs during execution, the transaction is rolled back (Rollback) to the state before the transaction begins, as if the transaction had never been executed.

Consistency
A transaction can encapsulate a state change (unless it is a read-only). A transaction must always keep the system in a consistent state, regardless of the number of concurrent transactions at any given time.
That is, if the transaction is multiple concurrent, the system must act as if it were a serial transaction. Its main characteristics are protection and invariance (preserving an invariant), in the case of transfer cases, assuming that there are five accounts, each account balance is 100 yuan, then five accounts total is 500 yuan, if there are multiple transfers between the 5 accounts, regardless of the number of concurrent, For example, between A and B account transfer 5 yuan, between C and D account transfer 10 yuan, between B and E transfer 15 Yuan, five account total should also be 500 yuan, this is the protection and invariance

Isolation of
The isolated state performs transactions so that they appear to be the only operations that the system performs within a given time. If there are two transactions that run at the same time and perform the same function, the isolation of the transaction will ensure that every transaction in the system considers only that the transaction is in use by the system. This attribute is sometimes called serialization, and in order to prevent confusion between transactional operations, the request must be serialized or sequenced so that only one request is used for the same data at a time.

Durability
After the transaction completes, the transaction changes made to the database are persisted in the database and are not rolled back.
Because an operation typically contains many sub-operations that can cause problems with hardware corruption or other factors, it is not easy to implement acid correctly. The acid recommendation database takes all data that needs to be updated and modified once, but it is not practical.
There are two main ways to achieve acid: the first is write ahead logging, which is the way of journaling (modern databases are based on this approach). The second type is shadow paging.

ACID: Four essential elements for database transactions to execute correctly

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.