Chapter 6 of this book discusses Transactions. For decades, transactions have been the mechanism of choice for simplifying these issues. A transaction is a way for an application to group several reads and writes together into a logical unit. Conceptually, all the reads and writes in a transaction are executed as one operation: either the entire transaction succeeds (commit) or it fails(abort, rollback).
Transactions are created with a purpose: to simplify the programming model for applications accessing a database. By using transactions, the application is free to ignore specific potential error scenarios and concurrency issues.
Please refer to pdf to dive into the detailed notes.