INTRODUCTION
I've been learning DBMS and I came around a set of properties known as ACID. I'll be explaining ACID in brief here.
TRANSACTIONS
So a set of connected operations in DBMS which work as a single unit of logic are known as Transactions. The main operations of transactions are Read and Write.
To understand further I read some oracle docs on Transactions. So, for example, a customer transfers some money from one account to another account it's a transaction but when you delve deeper you'll find some operations which are making this transaction possible. These are
Decrementing the amount in the initial account.
Incrementing the amount in the final account.
Recording this change in a journal.
Now, this is where it gets interesting. Imagine a situation if some error persists and prevents any one of the operations from completing it will cause a blunder! or what if there was some manual error and the customer entered the wrong account number! In this case, the database has to roll back to its initial state despite some operations that have already been completed, to prevent any discrepancy.
This can be achieved if the transaction follows some basic properties of the transaction. Transactions are trivial and require a strict set of properties to be successful and useful. These properties are known as 'ACID'.
ACID stands for
- Atomicity
- Consistency
- Isolation
- Durability
Let's get in deeper into what these words mean!
ATOMICITY
This is the property that saved the customer after the error in the completion of one or more operations in the above example.
It says that either the entire transaction takes place at once or doesn't happen at all. This makes sure that the transactions do not occur partially.
The two operations that take place in Atomicity are
- Abort
- Commit
these are Database Manipulation Commands. So the database must not be inconsistent and Atomicity ensures so.
Next up is 'C' i.e. Consistency.
CONSISTENCY
The transaction should result in a change of the Database from one consistent state to another consistent state. It refers to the correctness of a database. So in the above example if it goes as planned the total amount of both the accounts before and after the transaction must be the same.
The third property 'I' Isolation.
ISOLATION
Isolation means each transaction executes alone and is not visible to other transactions until it is committed or stored in the main memory. It means that multiple transactions can occur currently without leading to the inconsistency of the database state. It may seem like the transactions are executing serially.
Fourth and last property 'D' Durability.
DURABILITY
The changes made by the committed transaction must be permanent. This property ensures that once the transaction has completed execution, the updates and modifications to the database are stored in and written to disk and they persist even if a system failure occurs. These updates must be permanent and stored in non-volatile memory. Thus the effects of the transaction should not be lost.
Wrapping up, these 'ACID Properties' ensures the correctness and consistency of a database.
Hope this blog made 'ACID' clear to you :) Refer https://docs.oracle.com/database/121/CNCPT/transact.htm#CNCPT037 to read more in detail.