A database transaction is a unit of interaction with a Database management system or similar system that is treated in a coherent and reliable way independent of other transactions. Ideally, a database system will guarantee all of the ACID properties for each transaction. In practice, these properties are often relaxed somewhat to provide better performance.
A single transaction might require several queries, each reading and/or writing information in the database. When this happens it is usually important to be sure that the database is not left with only some of the queries carried out. For example, when doing a money transfer, if the money was debited from one account, it is important that it also be credited to the depositing account. Also, transactions should not interfere with each other. For more information about desirable transaction properties, see ACID.
- Begin the transaction
- Execute several queries (although any updates to the database aren't actually visible to the outside world yet)
- Commit the transaction (updates become visible if the transaction is successful)
- Distributed transaction
- Nested transaction
- ACID properties