My personal notes for ACID

An article from Wikipedia

What happens if the power fails partway through a series of database operations? ACID (atomicity, consistency, isolation, durability) is a set of principles that can be applied to transactions to ensure they’re valid. These ideas were coined during the 1970s and 1980s, and exist in database systems today.

  • Atomicity: Each transaction is treated as a single unit. Either all of the operations in the transaction succeed, or none of them do. This prevents the “bank transfer” problem, where money is removed from one account but not applied to another.
  • Consistency (correctness): The transaction must bring the database from one valid state to another. This includes things like database constraints, cascades and triggers. For example, if an operation in a transaction had a trigger, but the trigger was not applied when the transaction was completed, then the database would not be consistent.
  • Isolation: If multiple transactions are executing concurrently, this principle ensures the result would be the same as if they were executing sequentially. Another way of viewing this is “how and when the changes made by one operation become visible to others.”
  • Durability: “Once a transaction has been committed, it will remain committed even in the case of a system failure (e.g., power outage or crash). In simplified terms, this means transactions are written to disk. This is especially important in distributed database systems, where multiple servers must coordinate.