Isolation levels

Transaction Isolation levels, examples in Java with MySQL

Introduction

Before we demonstrate Isolation levels, we must define transactions and what ACID model is. Isolation levels are one of ACID model properties, Isolation.

A Transaction represents a collection of operations executed sequentially as one single operation. Consider the well know example of money transfer between two bank accounts of Alice and Bon. Money transfer involves the following operations: 

  1. Read Alice’s account, by issuing a select statement, to check if Alice has X-amount or more for the transfer. 
  2. Read Bob’s account, by issuing a select statement, to check if Bob’s account can receive money. 
  3. Decrease Alice’s account by X-amount of money. 
  4. Increase Bob’s account by X-amount of money. 

In RDBMS for a unit of work to qualify as transaction it must comply to ACID model. So, what is ACID model ?