|
Answer» In a SQL Database, every transaction must follow some specific set of properties. These properties are referred to as ACID properties. They are as follows: - A for Atomicity: This 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. For example, consider a bank transaction from one account to another. The transaction must either be completed entirely or must be FAILED. There cannot be a midway transaction such as money has been debited from one account but has not been credited to the other account.
- C for Consistency: This property implies that integrity constraints must be fulfilled before and after the transaction to ensure that the database is consistent. It refers to a database's correctness.
For example, if a bank transaction is performed from account A having X money to an account B having Y money, then after the transaction has been performed the total amount of money must remain the same, that is, X + Y. - I for 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.
For example, a bank has many ATMs present in a country. All of the ATMs can operate at the same time. They function as if they are the only transaction being performed on the bank’s database thereby, implementing isolation. - D for Durability: This attribute ensures that once a transaction has completed execution, the database updates and modifications are saved and written to memory and that they SURVIVE even if the system fails. These modifications are now saved in non-volatile memory and are permanent. As a result, the transaction's effects are never lost.
For example, a backup database must be maintained so that if in any case, the primary database fails, we can recover the data from the backup database.
|