ACID-Property of Databases Transactions

Posted By: Vaishnavi Mall Published: 14, Jan 2024

ACID-Property of Databases Transactions


ACID-Property of Databases Transactions


What is a transaction in a database?


A transaction is a logical unit of work that may or may not change the database from one consistent state to another. The major point to be maintained while handling databases as a part of web development is to maintain their consistency all the time. A consistent database is a key to a successful dynamic application. For achieving this we have to follow certain properties to ensure data accuracy, completeness, and data integrity.


What are the different properties of a database system?


  • Atomicity

    A transaction is an atomic unit of operation. Either it executes entirely or does not execute at all. It must not be left at a partial state. If a transaction commits i.e if it is completely executed without any errors then the changes are visible in the database otherwise if the transaction aborts i.e. if it is not executed properly because of some error then the changes done by it will not be saved at all and will not be visible in the database. Let's take an example: Suppose the user fills a registration form in which he fills data about himself like email, password, name, phone no. A post request is made to submit the form and save the data into the database. If the email entered by the user already exists in the database and assuming the E-mail field is unique then the transaction must abort and no changes should be made in the database. This property is known as atomicity i.e even if only one field is causing an error the whole transaction must abort.


  • Consistency

    Consistent property of the database means that before and after a transaction occurs the database should remain in a consistent state. The database integrity must be maintained at all costs. Once a transaction is committed the database should move from one consistent state to another. Let’s take an example to understand it better. Suppose In a company database we have an employee table that has two fields: total leaves available and total leaves taken by an employee. If an employee takes 5 days to leave two transactions should take place in the database. Firstly the total leaves available should be decreased by 5 and secondly, the total leaves taken by the employee should be increased by. Here is where consistency comes into the picture the sum of the values of those fields for an employee before the transaction must be equal to the sum of the values of those fields after the transaction.

Total Leaves Available Total Leaves Taken SUM
Before transaction 15 5 20
After transaction 10 10 20

  • Isolation

    Isolation property maintains the concurrency of the database without causing any inconsistency in the database. In a database management system, multiple transactions can run parallelly so they must occur in isolation so that changes of one transaction should not adversely affect the other. Now let’s see an example to make it more clear: Suppose two users are trying to buy the last copy of a Book from an e-commerce website so in this case only one transaction should be completed.


  • Durability

    The durability of the database system means after a transaction is successfully committed the database should be able to update and modify the changes properly even in the case of system failures. For example, If a transaction has successfully occurred and the power supply is lost then the database must make the modification once the power supply is retrieved.

contact us

Get Free Professional Consultation

Corporate Address

Sultanpur, New Delhi 110030


Registered Address

Dinesh Vihar Meerut, 250002

hello@figmanetsolutions.com

Mon - Sat (9AM to 7PM)


Get in Touch

Let’s Discuss Your Project in Details


Let’s explore your project in detail, focusing on key elements like goals, audience, features, and timelines to set you up for success.