Databases: ACID & BASE
ACID In the realm of database management, ensuring the reliability and integrity of data is paramount. This is where the ACID principles come into play. ACID, an acronym for Atomicity, Consistency, Isolation, and Durability, represents a set of properties that guarantee reliable processing of database transactions. These principles are foundational to traditional relational database management systems (RDBMS) and are crucial for applications where data accuracy and consistency are non-negotiable. Before we start, let's recap what is the transaction: Transaction - is a sequence of one or more queries executed as a single unit of work. The main principle of a transaction is "all or nothing", meaning: If all queries in the transaction succeed, the changes are safely saved in the database. If any query in the transaction fails, all changes are undone, restoring the database to its original state before the transaction started. ⚠️ When changes are saved, we say the transaction is committed. If changes are undone, the transaction is rolled back ⚠️ Imagine you are buying a laptop from an online store. When you click "Place Order", several things must happen in the database: Check if the laptop is in stock. Deduct the laptop from the stock. Charge your credit card. Create an order record in the system. Send a confirmation email. We can think of it as a single unit of work. Let's also consider that each query interacts with various tables:

ACID
In the realm of database management, ensuring the reliability and integrity of data is paramount. This is where the ACID principles come into play. ACID, an acronym for Atomicity, Consistency, Isolation, and Durability, represents a set of properties that guarantee reliable processing of database transactions. These principles are foundational to traditional relational database management systems (RDBMS) and are crucial for applications where data accuracy and consistency are non-negotiable.
Before we start, let's recap what is the transaction:
Transaction - is a sequence of one or more queries executed as a single unit of work. The main principle of a transaction is "all or nothing", meaning:
- If all queries in the transaction succeed, the changes are safely saved in the database.
- If any query in the transaction fails, all changes are undone, restoring the database to its original state before the transaction started.
⚠️ When changes are saved, we say the transaction is committed. If changes are undone, the transaction is rolled back ⚠️
Imagine you are buying a laptop from an online store. When you click "Place Order", several things must happen in the database:
- Check if the laptop is in stock.
- Deduct the laptop from the stock.
- Charge your credit card.
- Create an order record in the system.
- Send a confirmation email.
We can think of it as a single unit of work. Let's also consider that each query interacts with various tables: