A transaction is any unit of work done against the database.A transaction can be used to save the changes made to the database, it can be used to rollback the database to any save point.
For example say if you are creating or updating a record or deleting a record from the table then you are performing a transaction. A transaction is very useful for keeping the database in a free from errors and also provides the data integrity. Transaction is based on important properties which are also known as ACID properties.
Atomic The implication of this property is pretty simple, a transaction must be treated as an atomic unit, meaning execution must happen either for all of its operations are or none. At no stage in a database transaction should be left partially completed. It is recommended that the best way to define states is either before the execution of the transaction or after the execution/abortion/failure of the transaction.
Consistency Its paramount for the database to remain in a consistent state after any transaction. There shouldnt be any adverse effect on the data present in the database. The database has to remain consistent after the execution of the transaction if it was in a consistent state before the execution of a transaction.
Durability Durability of the database is highly required when it comes to hold all its latest updates. It has to be the case even if the system fails or restarts. The database has to hold the modified data in case a transaction updates a chunk of data in a database and commits. The condition when data is updated once the system springs back into action is when a transaction commits but the system fails before the data could be written on to the disk.
Isolation In a database system, the property of isolation calls for carrying out and executing all the transactions as if it is the only transaction in the system, especially when more than one transaction are being executed simultaneously and in parallel in a database system. The existence of any other transaction cannot be affected by any transaction.