8 Executing Multi-Document ACID Transactions
This chapter covers
- Understanding the WiredTiger Storage Engine
- Refreshing the ACID principles
- Comparing the Core API and Callback API
- Implementing transactions with the Node.js driver
- Performing transactions using the Python driver
- Managing transactions with the Ruby driver
Transactions are discrete units of operation within a database management system, comprising multiple related read and write actions. These operations are grouped together and must either all succeed as a whole or fail together, ensuring that no partial updates are left in the database. For example, consider a transaction for booking a travel package that includes a flight and a hotel. If the booking process successfully reserves a flight but encounters an issue with the hotel reservation, the entire transaction must be aborted. This means the flight reservation would also be undone, maintaining the status quo in the database.
While MongoDB is a non-relational database and traditionally does not follow the relational model's approach to transactions, it has long ensured data integrity through its single-document operations. However, with the introduction of multi-document ACID transactions, MongoDB has significantly broadened its applicability and enhanced its capability to handle complex transaction scenarios.