R Purchasing an item with foreign currency → Lesson 2: price_paid → Lesson 3: Transactions players player_id PK nickname level balance items item_id PK name price purchases purchase_id PK player_id > players item_id > items price_paid bought_at https://dbdiagram.io/d/6a9829aa5450bea1bece2959 BEGIN; UPDATE players SET balance = balance - 100 WHERE player_id = 1 AND balance >= 100; -- if 0 rows — not enough money, roll back INSERT INTO purchases (player_id, item_id, price_paid, bought_at) VALUES (1, 5, 100, now()); COMMIT; Here's the player's bet: the two tables must either change together or not change at all.