A transaction is a single logical unit of work which 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 transaction, certain properties are followed. T hese are called ACID properties.

  • Atomicity:

    Atomicity is also known as the ‘All or nothing rule’.

    Each transaction is considered as one unit and either runs to completion or is not executed at all. There is no midway i.e. transactions do not occur partially. It involves following two operations.
    • Abort: If a transaction aborts, changes made to database are not visible.
    • Commit: If a transaction commits, changes made are visible.

  • Consistency:

    Database state is consistent before and after the transaction. It has to do with Referential Integrity: A transaction should not try to delete a row whose primary key is foreign key in at least one other table, if the record with the foreign key is not deleted before.

  • Isolation:

    Isolation is all about Concurrency Control i.e having concurrent transactions in safe and proper way. Two transactions should not try to modify the same data at the same time. If two transactions are to work on same data then one must wait for the other transaction to get complete. More on this here.

  • Durability: 

    Durability is all about data persistence. All data modification done by a transaction should be stored in some non-volatile memory when a transaction succeeds. An example of durability failure is Consider a transaction that transfers 10 from A to B. First it removes 10 from A, then it adds 10 to B. At this point, the user is told the transaction was a success, however the changes are still queued in the disk buffer waiting to be committed to disk. Power fails and the changes are lost. The user assumes (understandably) that the changes persist.
ACID property is an intrinsic property of RDMS and it is what makes SQL databses stand out even when they come with scalability challenges(having huge possibility of vertical scale but very limited possibility of horizontal scale). ACID properties are very crucial in certain industries like finance industry (Banks), where the customers need to see the correct amount all the time. That is one of the reasons Banks use RDBMS rather than NoSQL databases. RDBMS comes with ACID properties out of the box.

The ACID properties, in totality, provide a mechanism to ensure correctness and consistency of a database in a way such that each transaction is a group of operations that acts a single unit, produces consistent results, acts in isolation from other operations and updates that it makes are durably stored.

The above content is written by:

Abhishek Dey

Abhishek Dey

A Visionary Software Engineer With A Mission To Empower Every Person & Every Organization On The Planet To Achieve More

Microsoft | University of Florida

View LinkedIn profile

If you have any feedback, please use this form: https://thealgorists.com/Feedback.

Subscribe to Our Youtube Channel

Follow Us On LinkedIn