Database Transactions

Learn how to ensure data consistency using database transactions, what ACID means, and what we can do when transactions are unavailable.

Relational databases provide us with a tool for improved consistency. We can feel secure knowing that our application can crash during a complex update because of database transactions.

Some updates require multiple database queries, and an error in the middle of an update can leave the database in an invalid state. Database transactions solve this issue by grouping multiple SQL commands into one big update.

Why do we need transactions?

Let’s look again at our example schema for a theater application. This time we’re interested in the orders and tickets tables. And, this time, the orders table has an amount property containing the amount of money we want to request from the user.

Get hands-on with 1200+ tech skills courses.