# ACID

**ACID** stands for **Atomicity, Consistency, Isolation** and **Durability** , which are four important properties to ensure when performing any transactional operations with [the database](https://vietnix.vn/database-la-gi/) . Specifically, these are the requirements for safety, sustainability and [data](https://vietnix.vn/du-lieu-la-gi/) integrity . If a process does not ensure the above properties, it will not be able to perform operations with data and will be canceled immediately.

### ACID properties in databases <a href="#cac-thuoc-tinh-cua-acid-trong-co-so-du-lieu" id="cac-thuoc-tinh-cua-acid-trong-co-so-du-lieu"></a>

Each process requires all 4 ACID properties to participate in transactions, specifically the properties: **Atomicity** , **Consistency** , **Isolation** , and **Durability** . ), As follows.

#### 1. Atomicity <a href="#id-1-atomicity" id="id-1-atomicity"></a>

**Atomicity** can be understood as atomicity. This means that any changes to the data must be complete if the processes execute successfully or there will not be any changes to the data if a process failure occurs.

<figure><img src="https://static-xf1.vietnix.vn/wp-content/uploads/2022/08/Atomicity-1024x597.webp" alt="Atomicity" height="597" width="1024"><figcaption><p>Atomicity</p></figcaption></figure>

When a chain of processes manipulates the database, if an error occurs, all of these processes must be canceled, the data in the database remains unchanged. In case there are no unusual errors during the processing process, the data will be updated according to the user's wishes.

It is called atomic property because each individual operation is considered like electrons moving around the nucleus and when the nucleus moves, these electrons also move. There will not be any electrons that deviate from their original orbit.

#### 2. Consistency <a href="#id-2-consistency" id="id-2-consistency"></a>

**The Consistency** attribute requires data consistency for the database. When a Transaction is completed, all data must be preserved regardless of whether the operation succeeds or fails.

<figure><img src="https://static-xf1.vietnix.vn/wp-content/uploads/2022/08/Consistency-1024x614.webp" alt="Consistency" height="614" width="1024"><figcaption><p>Consistency</p></figcaption></figure>

Data in the database must always be in a valid state at any time, before and after performing each Transaction action. This means that if the first action of the process fails, it will either rollback, or the next process will not be performed.

#### 3. Isolation <a href="#id-3-isolation" id="id-3-isolation"></a>

**Isolation** is a property that refers to the independence of Transactions when executing concurrently on the system. If there are multiple processes occurring at the same time, a mechanism is needed to ensure that these processes can operate in parallel without affecting each other.&#x20;

For example, in the case of a customer transferring money to a bank and an accountant withdrawing money from the bank at the same time. At this time, the database will simultaneously perform two actions: adding to the customer's balance and subtracting the amount withdrawn by the accountant. There will be a mechanism for both of these actions to take place successfully in parallel without affecting database processing.

#### 4. Durability <a href="#id-4-durability" id="id-4-durability"></a>

This property is provided to ensure that when Transactions take place successfully, the effect it creates on the database must be sustainable. No matter what error occurs in the system, the data is always restored to its original state.

For example, for money transaction processes through banks. When Transactions are completed, data will be recorded on hard disk, transactions will also be recorded. If any problem occurs, you can easily [back](https://vietnix.vn/backup-la-gi/) up the data.
