...

What is Concurrency and Transaction in DBMS?

What is Transaction in DBMS?

The transaction is one of the most important concepts in the database management system. A transaction essentially represents any change in the user database. The most common way to think of a transaction is by transferring and withdrawing money from one database to another. Therefore, all in all, a transaction is a set of instructions/operations by which we can perform tasks inside databases.

ACID Properties of Transaction in DBMS

There are 4 properties that are popularly represented as ACID properties of transactions, ACID is an acronym given for the 4 properties that must be there in a transaction. These properties are-:

Atomicity

Atomicity in transactions means that all the processes must be completed in a transaction. If there is any process that is left incomplete in a transaction, then the transaction is aborted. This means that a transaction is considered a single unit of work.

Consistency

Consistency in the transaction means that the sum total after any transaction from A to B must be the same as it was before. Consistency essentially says that if the database was consistent before the transaction, it must be consistent after the transaction. For example, if Mark has 200 dollars in his bank account and Millie has 400 dollars, the sum total of both accounts is 600 dollars, If Millie sends a hundred dollars to Mark, the sum total of both accounts remains the same. This is known as consistency in the database.

Isolation

The property of isolation in the transaction ensures that the data used during the execution of a transaction cannot be used by another transaction until the first one is completed. In simple words, if one transaction is not interfering with the process of any other transaction, then the property of isolation is fulfilled.

Durability

Durability in the transaction means that if a transaction is completed, then it must remain in that state permanently until the next transaction. For example: if your account is credited for 200 dollars and your balance is 600 dollars, then the balance should remain the same until the next transaction is performed. 

Working of Transaction in Databases

Events such as buying an item, a course, or a movie ticket trigger a database transaction. The transaction is a vital process and therefore the process must be secured and safe. Any transaction that happens consists of several parts, a normal transaction consists of two parts-:

  1. Firstly, we have to UPDATE the inventory, this UPDATE will subtract the number of units asked by the consumer from the PRODUCT table.
  2. Secondly, we have to UPDATE the customer’s RECEIVABLE table by adding the number of units.

Above are the least number of steps required for a transaction in sales.

The execution process of a transaction is a critical database management activity because if any process is incomplete, data integrity will be compromised. 

What Is Concurrency in Databases?

Concurrency in the database means that multiple transactions are happening to a database all at once. When many users are able to access the database, the number of concurrent transactions tends to grow rapidly, therefore, concurrency control is absolutely necessary and important in a multiuser database work environment.

tanesh

Founder Of Aipoint, A very creative machine learning researcher that loves playing with the data.