1. Definition: A transaction is a user-defined sequence of database operations that are either fully or completely non-operational and are an inseparable unit of work.
2. Main function: Ensure the integrity and validity of database data.
3. For example, in bank data, the operation from account A to 1000 to another account B is comprised of two indivisible operations in the database system: Modify account A, minus the transfer amount of 1000, modify account B and increase the transfer amount by 1000. This behavior is not allowed: only account A has been modified, minus the transfer amount of 1000, and no account B has been modified. A transaction can execute a series of indivisible database operations as a whole.
4. Properties: Acid Properties
Atomicity: A transaction is a logical unit of work for a database, and all operations included in a transaction are either done or not.
Consistency: The result of a transactional execution must be a state in which the database changes from one consistent state to another.
Isolation: The execution of transactions and transactions is isolated, that is to say: The execution of a transaction cannot be disturbed by other transactions.
Persistence: It also becomes permanent, that is to say: Once a transaction is committed, its changes to the data in the database will be permanent.
5. Factors affecting the transaction:
First: A transaction is forced to stop during operation
Second: When multiple transactions are executed, there is a cross between different transaction operations.
Introduction to transactions in the database