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:
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)