database transaction acid

A few days ago, I encountered the term ‘ACID’ when reading one article about database. I summarized the term in this post after searching it using google, so that it can be referenced later.

  • Atomicity

Transactions are often composed of multiple SQL statements. Atomicity guarantees that all of the statements in the transaction succeeds completely, or if any of the statements fails, the transaction fails and the database is left unchanged. This means if the transaction fails, the statements that even succeed will be rolled back.

  • Consistency

Consistency ensures that a transaction only bring the database from one valid state to another valid state. Any data written to the database must be valid according to the defined rules.

  • Isolation

Transactions are often executed concurrently. Isolation ensures that the transaction executed concurrently leaves the database in the same state as if the transaction were executed sequentially. This means no transaction will be affected by any other transaction .

  • Durability

Durability guarantees that once a transaction has been committed, it will remain in the system, even if there is a system crash immediately following the transaction . This means any changes made by the transaction must be stored permanently.