DEV Community

Cover image for ACID Transactions
Luke
Luke

Posted on • Originally published at linkedin.com

ACID Transactions

Have you ever heard the phrase "ACID Transactions"?

  • If yes, this post is for you ๐Ÿ˜Ž
  • If not, now you know it ๐Ÿ˜

What are transactions?

In normal life, transactions occur when you sell - I buy and vice versa. It represents the process between you and me when we give something to each other with the same value, maybe money or another thing with the same price.
In SQL, it is another definition, transactions is a unit or sequence of work that is performed on a database. It can be made manually by the user or automatically by the software. For example:

Unit

Unit Transaction

Sequence

Sequence Transaction

What are ACID transactions?

ACID is an acronym that refers to the set of 4 key properties of a transaction. Each of them are:

  • Atomicity (A)
  • Consistency (C)
  • Isolation (I)
  • Durability (D)

Atomicity

Ensures that a transaction is either fully committed or not executed at all. In other words, if any part of the transaction fails, the entire transaction is rolled back, and no changes are applied to the database. This property maintains the accuracy and reliability of the database by treating the transaction as an indivisible unit of work

Consistency

Ensures that the database remains valid both before and after a transaction. In simpler terms, the database schema must adhere to all constraints and rules. If any transaction violates these constraints, it is rolled back, preserving the databaseโ€™s integrity and ensuring accurate and reliable data.

Isolation

Ensures that each transaction operates independently of other transactions, which means that a transactionโ€™s effects should only become visible to other transactions after it has been committed.

Durability

Ensures that any changes made to the database during a transaction are permanent, even in the event of system failure. Once a transaction is committed, its effects persist, even if the system is destroyed or experiences power loss

ACID Transactions Use Case

You can apply it to systems that require high reliability and consistency like:

  • Banking
  • Healthcare
  • E-commerce

Summary

This is what I know about ACID transactions. Hope you can get some extra knowledge through my post.

Happy coding ๐Ÿ˜Ž!

Top comments (0)