Suggest an editImprove this articleRefine the answer for “How do transactions ensure data consistency?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)Transactions ensure **data consistency** because each one checks the database's rules and constraints (foreign keys, unique values, `CHECK` constraints, triggers), preserves logical integrity, and uses rollbacks (`ROLLBACK`) if something fails along the way. **Key point:** for example, if a transaction is supposed to save an order and deduct stock from a warehouse, but the deduction fails, the entire process gets cancelled, so the database never ends up in a state where the order exists but the stock doesn't.Shown above the full answer for quick recall.Answer (EN)ImageTransactions ensure **data consistency** because each one: 1. **Checks the database's rules and constraints**, foreign keys, unique values, `CHECK` constraints, triggers. If even one condition is broken, the transaction never commits. 2. **Preserves logical integrity**, the data stays in a state consistent with business logic after the transaction runs. 3. **Uses rollbacks (**`ROLLBACK`**)**, if something fails, the database returns to its last consistent state. Example: if a transaction is supposed to save an order and deduct an item from stock, but the deduction fails, the whole process gets cancelled. So the database never ends up in a state where the order exists but the stock doesn't.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.