I’ve been using Alan Beaulieu’s Learning SQL to teach my SQL Development class with MySQL 8. It’s a great book overall but Chapter 12 lacks a complete exercise. Here’s all that the author provides to the reader. This is inadequate for most readers to work with to solve the concept of a transaction.
Exercise 12-1
Generate a unit of work to transfer $50 from account 123 to account 789. You will need to insert two rows into the transaction table and update two rows in the account table. Use the following table definitions/data:
Account:
account_id avail_balance last_activity_date
----------- -------------- ------------------
123 450 2019-07-10 20:53:27
789 125 2019-06-22 15:18:35
Transaction:
txn_id txn_date account_id txn_type_cd amount
------ ---------- -------+-- ----------- ------
1001 …[Read more]