databases/database-transactions-why-moving-money-is-all-or-nothing.md
Database transactions: why moving money is all or nothing
Paying someone is really two changes in a database: take money from one account, add it to another. If the power dies between them, money vanishes.
A transaction bundles the changes so they happen all together or not at all. Pull the plug yourself in the interactive, then run real Python and SQLite code to see BEGIN, COMMIT and ROLLBACK keep the data safe.

$ ls databases/
see all →
databases/what-is-a-database-index-find-one-row-without-reading-them-all.md
What is a database index? Find one row without reading them all
Ask a database for one person among a million rows and it could read every row until it finds them. That is slow. An index is the…
databases/your-first-sql-query-ask-a-table-of-pets-a-question.md
Your first SQL query: ask a table of pets a question
SQL is the language you use to ask a database questions, and five words get you surprisingly far: SELECT, FROM, WHERE, ORDER BY and LIMIT…
databases/why-databases-split-your-data-into-two-tables-and-link-them-by-id.md
Why databases split your data into two tables (and link them by id)
A database table looks like a spreadsheet: columns for each kind of information, one row per thing. But it comes with rules. Every column…