ACID Properties in DBMS

Home  >  Articles  >  ACID Properties in DBMS

ACID Properties in DBMS

Kanika Goyal

Updated on 18th July, 2024 , 5 min read

A transaction is a single logical unit of work that accesses and possibly modifies the contents of a database. Transactions access data using read and write operations.
In order to maintain consistency in a database, before and after the transaction, certain properties are followed. These are called ACID properties.

Atomicity

The term atomicity defines that the data remains atomic. It means if any operation is performed on the data, either it should be performed or executed completely or should not be executed at all. It further means that the operation should not break in between or execute partially. In the case of executing operations on the transaction, the operation should be completely executed and not partially.

Example: If Remo has account A having $30 in his account from which he wishes to send $10 to Sheero's account, which is B. In account B, a sum of $ 100 is already present. When $10 will be transferred to account B, the sum will become $110. Now, there will be two operations that will take place. One is the amount of $10 that Remo wants to transfer will be debited from his account A, and the same amount will get credited to account B, i.e., into Sheero's account. Now, what happens - the first operation of debit executes successfully, but the credit operation, however, fails. Thus, in Remo's account A, the value becomes $20, and to that of Sheero's account, it remains $100 as it was previously present.

ACID Properties in DBMS

In the above diagram, it can be seen that after crediting $10, the amount is still $100 in account B. So, it is not an atomic transaction.

The below image shows that both debit and credit operations are done successfully. Thus the transaction is atomic.

ACID Properties in DBMS

Thus, when the amount loses atomicity, then in the bank systems, this becomes a huge issue, and so the atomicity is the main focus in the bank systems.

Consistency

The word consistency means that the value should remain preserved always. In DBMS, the integrity of the data should be maintained, which means if a change in the database is made, it should remain preserved always. In the case of transactions, the integrity of the data is very essential so that the database remains consistent before and after the transaction. The data should always be correct.

Example:

ACID Properties in DBMS

In the above figure, there are three accounts, A, B, and C, where A is making a transaction T one by one to both B & C. There are two operations that take place, i.e., Debit and Credit. Account A firstly debits $50 to account B, and the amount in account A is read $300 by B before the transaction. After the successful transaction T, the available amount in B becomes $150. Now, A debits $20 to account C, and that time, the value read by C is $250 (that is correct as a debit of $50 has been successfully done to B). The debit and credit operation from account A to C has been done successfully. We can see that the transaction is done successfully, and the value is also read correctly. Thus, the data is consistent. In case the value read by B and C is $300, which means that data is inconsistent because when the debit operation executes, it will not be consistent.

Isolation:

This property ensures that multiple transactions can occur concurrently without leading to the inconsistency of the database state. Transactions occur independently without interference. Changes occurring in a particular transaction will not be visible to any other transaction until that particular change in that transaction is written to memory or has been committed. This property ensures that the execution of transactions concurrently will result in a state that is equivalent to a state achieved these were executed serially in some order.
Let = 500, = 500.
Consider two transactions and T”.

Suppose has been executed till Read (Y) and then T’’ starts. As a result, interleaving of operations takes place due to which T’’ reads the correct value of but the incorrect value of and sum computed by
T’’: (X+Y = 50, 000+500=50, 500)
is thus not consistent with the sum at end of the transaction:
T: (X+Y = 50, 000 + 450 = 50, 450) .
This results in database inconsistency, due to a loss of 50 units. Hence, transactions must take place in isolation and changes should be visible only after they have been made to the main memory.

Durability:

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 now become permanent and are stored in non-volatile memory. The effects of the transaction, thus, are never lost.

 

Advantages of ACID Properties in DBMS:

  1. Concurrency Control: ACID properties help to manage multiple transactions occurring concurrently by preventing interference between them.
  2. Data Consistency: ACID properties ensure that the data remains consistent and accurate after any transaction execution.
  3. Recovery: ACID properties ensure that in case of any failure or crash, the system can recover the data up to the point of failure or crash.
  4. Data Integrity: ACID properties maintain the integrity of the data by ensuring that any changes to the database are permanent and cannot be lost.

Disadvantages of ACID Properties in DBMS:

  1. Complexity: Implementing the ACID properties can increase the complexity of the system and require significant expertise and resources. Overall, the advantages of ACID properties in DBMS outweigh the disadvantages. They provide a reliable and consistent approach to data
  2. Performance: The ACID properties can cause a performance overhead in the system, as they require additional processing to ensure data consistency and integrity.
  3. management, ensuring data integrity, accuracy, and reliability. However, in some cases, the overhead of implementing ACID properties can cause performance and scalability issues. Therefore, it’s important to balance the benefits of ACID properties against the specific needs and requirements of the system.
  4. Scalability: The ACID properties may cause scalability issues in large distributed systems where multiple transactions occur concurrently.

Similar Articles

D Pharmacy

By - Nikita Parmar 2024-07-06 03:12:58 , 3 min read
Read More

Frequently Asked Questions

What are the ACID properties in DBMS?

It stands for Atomicity, Consistency, Isolation, and Durability. These are a set of properties that guarantee the reliable execution of database transactions. ACID properties ensure that database transactions are processed accurately without interference.

What is an example of ACID in DBMS?

A bank transfer from Account A to Account B demonstrates ACID properties. Debiting from A and crediting B must either fully succeed or fully fail as per atomicity. Consistency ensures Account A has sufficient balance.

Why are ACID properties used in databases?

ACID properties provide consistency, integrity, and recoverability in databases. Following ACID principles, databases can maintain data accuracy despite crashes, errors, and concurrent transactions.

What is atomicity in DBMS?

The second reason listed for using transactions was atomicity. Atomicity means that multiple operations can be grouped into a single logical entity, that is, other threads of control accessing the database will either see all of the changes or none of the changes.

Check Eligibility   Free 1:1 Counselling