Transaction

You might say

Creating an order and deducting stock must succeed together; if any step fails, it must not leave half an order behind.

A group of related database operations that are committed or rolled back as a wholeWhen an order is created, the system usually writes the order record and deducts inventory together. If stock is unavailable, the order should not remain. A transaction rolls back this group of operations in the same database, but it does not automatically undo external actions like payments or emails.
Transaction Block
Further reading