A transaction is a mechanism, a sequence of operations that contains a set of database operations commands, all of which are submitted or revoked as a whole to the system, either executed or not, so that the transaction is a logical unit of work that is not an infringement, and the transaction acts as a logical element, Must have 4 acid properties, atomicity, consistency, isolation and durability.
1. atomicity
Atomicity refers to the fact that a transaction must perform a complete work, either to perform a modification of all the data, or to modify all data without execution.
2. Consistency
Consistency means that when a transaction is complete, all data must be in a consistent state, and in a relational database all rules must be applied to the modification of the transaction in order to maintain the integrity of all the data.
3. Isolation
Isolation means that the modification of a transaction must be isolated from the modifications of other parallel transactions, and when multiple transactions are in progress, they should not interfere with each other, and should prevent a transaction from being modified by other transactions as well as unreasonable access and incomplete reading of the data.
4. Persistence
Persistence is when a transaction is completed and its effects are persisted in the database system, that is, the modification is written to the database.
A transaction is a single unit of work, and if a transaction succeeds, all data modifications made in the transaction are committed and all data modifications are purged if the transaction encounters an error and must be canceled or rolled back. SQL Server 2005 database systems use transactions to ensure consistency of data and to ensure recoverability in the case of a system failure.
Transaction ACID Properties