liveBook · Manning

Database transaction

As explained in API Design Patterns

Transactional semantics are execution rules in which multiple data changes are committed together or rolled back together as one unit.

A database transaction groups multiple changes into one atomic unit: either every operation succeeds or the system rolls them all back. This prevents partial results when concurrent users modify a volatile dataset. section 18.1 section 17.3.6

Use transactional semantics when operations span resources or when intermediate states would be invalid:

  • For copying resources, preserve a consistent snapshot of the source while reading and creating destination entries. section 17.3.6
  • For moving resources, update identifiers and related references together so a failure does not leave the dataset partially changed. section 17.3.6
  • When a web API lacks generic transactions, consider transaction-like semantics for dependent requests, while recognizing that providing them is complex. section 18.1

Enabling a default logging configuration

Suppose a ChatRoom logging configuration must be enabled before it can become the default. Enabling it and assigning it as the default should either both succeed or both fail; otherwise the API can expose an invalid intermediate state. section 18.1

How API Design Patterns covers it

How deep it goes
Explains atomicity, snapshots, rollback, concurrency, and API limitations without detailing transaction implementation internals.
Examples
Uses resource copying, resource moving, and ChatRoom logging configuration updates as concrete cases.
What it assumes
Assumes familiarity with resources and database changes while establishing atomicity and rollback through practical API scenarios.
What you can do after
Evaluate when multi-resource operations require atomic or transaction-like semantics to avoid partial success.
How it connects
Connects atomicity with concurrency, snapshots, rollback, batch operations, resource copying, and resource moving.

Also explained in

Compare how 14 books explain database transaction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.