What is a transaction and four features of a transaction?
1. What is a transaction?
A transaction is a series of strict operations in an application. All operations must be completed successfully. Otherwise, all changes made in each operation will be revoked. That is to say, a transaction is atomic, and a series of operations in a transaction either succeed or do not.
There are two types of transactions to end. When all the steps in the transaction are successfully executed, the transaction is committed. If one of the steps fails, the rollback operation will occur, undo the operation that was performed before the start of the transaction.
Ii. ACID of transactions
Transactions have four features: Atomicity, Consistency, Isolation, and Durability ). These four features are short for ACID.
1. atomicity
A transaction is the logical unit of work of a database. All operations contained in a transaction are either done or not done.
2. Consistency
The result of event execution must be that the database changes from one consistent state to another consistent state. Therefore, when the database only contains the results of successful transaction commit, the database is in a consistent state. If a fault occurs in the database system, some transactions are forced to be interrupted before they are completed. Some of the changes made to the database by these unfinished transactions have been written to the physical database, the database is in an incorrect or inconsistent state.
3. Isolation
The execution of a transaction cannot be disturbed by other transactions. That is to say, the operations and data used within a transaction are isolated from other concurrent transactions, and each transaction that is executed concurrently cannot interfere with each other.
4. Continuity
It is also called permanent, which means that once a transaction is committed, its changes to the data in the database should be permanent. Other subsequent operations or faults should not affect the execution results.
The database system must maintain the following ACID features of transactions ):
Atomicity)
Consistency)
Isolation)
Durability)
Atomicity)
All operations in the transaction are either performed in full or not executed;
If the transaction has no guarantee of atomicity
When a fault occurs, the database may be inconsistent.
Status.