What is Transaction and ACID Properties

Transaction Concept:

A set of instructions that gets executed atomically for converting the database from one consistent state to another consistent state is called transaction.

OR

A group of DML instructions that gets executed atomically is called transaction.

Just like a C language function, Transaction also delimited by statements of the form begin transaction and end transaction. The transaction consists of all operations
executed between the begin transaction and end transaction.

To ensure integrity of the data, Each and every such transaction shall satisfy the following properties also called ACID properties:

Atomicity:

According to this property either all the instructions of the transaction gets executed or none. Read more on Atomicity with example

Consistency:

Execution of a transaction in isolation (that is, with no other transaction executing concurrently) preserves the consistency of the database.

Which means data in the database has to be consistent not only before the transaction but also after the transaction. Read more on Consistency with example

Isolation:

Even though multiple transactions may execute concurrently, the system guarantees that, for every pair of transactions Ti and Tj , it appears to Ti that either Tj finished execution before Ti started, or Tj started execution after Ti finished. Thus, each transaction is unaware of other transactions executing concurrently in the system.

in simple words any Transaction that is running, will never effect any other transaction in execution. Read more on isolation with example

Durability:

After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures.

which means in case if the transaction gets committed, then all the modifications done by transaction must and should exist in database irrespective of any possible failure. Read more on Durability with example

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s