A database transaction groups operations into a unit of work with defined consistency and completion semantics. It helps system commands address partial failures, concurrent updates, and business invariants such as a customer’s credit limit. Different transaction models provide different guarantees; the widely used ACID model is atomic, consistent, isolated, and durable. section 9.1.1
In a monolith with a single database, a system operation can often run as one transaction. The operation has a consistent view of data, and the database isolates it from concurrent operations. This usually makes the operation easier to implement, understand, and troubleshoot. section 6.1.1
Creating an order
A createOrder operation reads a product’s price, checks and reduces the consumer’s available credit, and creates an order. These changes must preserve the credit limit and avoid leaving a partially updated state if the operation fails. section 9.1.1
BEGIN TRANSACTION
SELECT * FROM PRODUCTS WHERE PRODUCT_ID = ?
UPDATE CONSUMER
SET AVAILABLE_CREDIT = AVAILABLE_CREDIT - ?
WHERE CONSUMER_ID = ?
AND AVAILABLE_CREDIT >= ?
INSERT INTO ORDERS (...) VALUES (...)
COMMIT TRANSACTION
The SQL listing groups the product lookup, conditional credit update, and order insertion between transaction boundaries. section 9.1.1
A system query can also use a transaction for a consistent view. In a monolith, findOrder can read the necessary data from one database and use a centralized transaction manager to isolate the entire query. A join across domain tables is possible, though it trades away domain module boundaries. section 12.1.4
Choose transaction boundaries with the operation’s architecture and workload in mind:
- Keep an operation in one transaction when practical. A transaction can span modules in a monolith, avoiding coordination among separate transactions. section 6.1.1 section 6.4.2
- Split bulk work into multiple transactions when this improves error handling, performance, or scalability. An operation can also be split into a synchronous part and later event handlers. section 6.1.1
- Expect redesign when moving an operation across services. Transactions are local to each service, so multiple transactions are not automatically isolated from one another. Coordination such as the Saga pattern adds consistency, concurrency, error-handling, and rollback concerns. section 6.1.1 section 6.4.2




















