A database transaction is a unit of work done within a database management system against a specific instance of a database. A complete database transaction should not violate the integrity of the database and should leave the data in a reliable and consistent state.
Properties of Transactions
Database transaction supports the following properties:
Any transaction within a database must be treated as an atomic unit. This simply means that all the operations within a single transaction must be executed. Otherwise, none should be performed, and therefore, no transaction should be partially completed. Simply atomicity avoids incomplete or partial updates to the database, which can bring data integrity issues.
A transaction should not cause data to change from its consistent state. If a database was in a consistent form before a particular transaction was executed, it should maintain consistency even after the execution of the transaction.
In a database system, sometimes you find that one or more transactions need to be executed simultaneously and in parallel. In such a case, no transaction should affect the existence of any other transaction. Therefore, isolation property describes how changes made in a particular transaction are kept hidden from other concurrently running transactions. This state will remain until a certain time when the concurrent transactions should be visible as per the defined rules.
Any updates made to the database and committed should remain permanent in the database even when the system restarts. The database should hold the changes made to the data. To ensure the durability of the data, all the transactions committed are copied to a transaction log and stored in secondary storage.