Two changes, one transaction.
One exchange at a time. Read what changes, then explain it in your own words before moving on.
- Meet the components
- Follow the steps
- Compare an example
- Check your understanding
Two changes, one transaction.
Example: ten fictional game points move between two records. This is a database model, not a payment service.
The application groups the dependent updates in one database transaction.
How to use this example
Select Next step to read at your own pace, or Animate step to watch one exchange. Nothing advances until you choose.
What it means
Everyday example
State in this scenario
Inspect components & read every step
- Game service
The fictional application requesting a points transfer.
Example: It asks the database to subtract and add points as one transaction.
- Database
An organized store of records that software can read and update.
Example: A shop stores product quantities and order records.
- Result
The outcome produced by the operation in this example.
Example: Read the current state and the step explanation to see what succeeded or failed.
Both changes commit
The application groups the dependent updates in one database transaction.
- Game service Database: BEGIN + changes. Subtract from one fictional record and add to the other within the transaction.
- Game service Database: COMMIT. The successful transaction is committed as one unit.
- Database Result: Success. The result reports a completed database transaction.
A condition fails
The application discards the transaction when a required condition is not satisfied.
- Game service Database: BEGIN + check. The application begins and checks the required conditions.
- Game service Database: ROLLBACK. A required condition fails, so the transaction is rolled back.
- Database Result: Not completed. The result explains that this attempted transfer did not commit.
Fictional teaching trace. One moving dot represents an exchange, not a measured network capture.