In the coffee chain's app every customer has an account: they top it up and pay for coffee from it. Anna wants to send Boris 30 rubles. For the database that is two statements: one UPDATE takes 30 from Anna's account, a second UPDATE adds it to Boris's. What happens if the server goes down between them? The money leaves Anna and never arrives.
In this lesson
- A transaction: all or nothing
- ROLLBACK throws the draft away
- Common mistake
- Key points