1.

What are ACID properties in Database Management Systems?

Answer»

The term "ACID" is an acronym for Atomicity, Consistency, Isolation and Durability. A transaction is a logical unit of work that accesses and, in CERTAIN cases, updates the contents of a database. Read and write operations are used by transactions to access data. Certain properties are followed before and after a transaction in order to preserve consistency in a database. ACID characteristics are what they are CALLED. Let us take a look at each of these characteristics in detail:

  • Atomicity: Atomicity means that either the complete transaction occurs at once or it does not OCCUR at all. There is no middle ground, which means that transactions do not take place in stages. Each transaction is treated as a single entity that is either completed or not conducted at all. It entails the following two procedures.
    • Abort: If a transaction aborts, any database modifications are lost.
    • Commit: When a transaction commits, the changes it contains become visible.

The 'All or nothing rule' is another name for atomicity.

Consider the following transaction T, which consists of two transactions: T1 and T2. 100 dollars transferred from account X to account Y.

If a transaction fails after T1 but before T2 (for example, after write(X) but before write(Y)), the amount deducted from X but not added to Y is deducted. As a result, the database is in an inconsistent condition. As a result, the transaction must be completed in its entirety to guarantee that the database state is valid.

  • Consistency: This means that integrity constraints must be maintained before and after the transaction to ensure that the database is consistent. It refers to a database's correctness. The ENTIRE amount before and after the transaction must be maintained, as SHOWN in the example above.

Before T, the total is 500 + 200 = 700.
After T, the total is 400 + 300 = 700.

As a result, the database is consistent. When T1 succeeds but T2 fails, there is inconsistency. As a result, T is not complete.

  • Isolation: This attribute assures that several transactions can take place at the same time without causing database state inconsistencies. Transactions take place in a non-interfering manner. Changes made in one transaction are not visible to other transactions until that transaction's update is written to memory or committed. This feature assures that concurrently executing transactions results in a state that is identical to the one attained if they were executed sequentially in some order. 

Let us take an example to understand Isolation. Let X = 500 and Y = 500 and let there be two transactions T and T".

Assume T has been running until Read (Y), at which point T" begins. As a result of this interleaving, T" reads the right value of X but the wrong value of Y, and the sum computed by T": (X+Y = 50, 000+500=50, 500) is inconsistent with the sum at the end of the transaction:

T = 50, 000 + 450 = 50, 450 (X+Y = 50, 000 + 450 = 50, 450).

Due to the loss of 50 units, this causes database discrepancy. As a result, transactions must be performed in isolation, and changes should only be seen after they have been written to the main memory.

  • Durability: This attribute ensures that after the transaction has been completed, the database updates and modifications are saved and written to disc and that they survive even if the system fails. These changes are now saved in non-volatile memory and are permanent. The transaction's effects are never lost as a result of this.

The ACID properties, taken together, provide a mechanism for ensuring the correctness and consistency of a database in such a way that each transaction is a group of operations that acts as a single unit, produces consistent results, is isolated from other operations, and the updates it makes are durably stored.



Discussion

No Comment Found