SQL: a family budget without guesswork
13 practical lessons from a first table to an auditable report and verified backup, on computers, tablets, and phones.
·
Every lesson is open: reading needs no account.
-
Why learn SQL: a family budget you can question
In the first lesson, we open a ready-made family-budget database and calculate income, spending, and savings with one query. SQL is useful when an answer must be exact, repeatable, and auditable rather than assembled by hand.
-
Tables, rows, columns, and NULL: model the budget first
We identify the project's accounts, categories, transactions, and limits, and separate a missing value from zero. Before learning syntax, understand the single fact represented by each row.
-
CREATE TABLE: a schema that rejects impossible data
Create the family-budget tables and move essential validation into the database.
-
INSERT and parameters: add spending safely
Insert one or several transactions and keep user values separate from SQL code.
-
SELECT: find the needed rows without changing them
Learn projection, filtering, stable sorting, and limiting a result.
-
CASE, COALESCE, and dates: turn stored facts into a useful view
Compute display columns, handle NULL honestly, and define month boundaries.
-
SUM, COUNT, GROUP BY, and HAVING: totals by category
Compress transactions into auditable totals and detect limits that were exceeded.
-
Keys and JOIN: connect transactions, accounts, and categories
Normalise the budget model and join tables by stable keys without multiplying rows.
-
Subqueries and WITH: answer a complex question in steps
Break the savings-rate calculation into named, testable CTE stages.
-
Window functions: a running balance without losing rows
Calculate the balance after every event and rank spending while keeping each source row.
-
Transactions and UPDATE: change everything or nothing
Make safe corrections and treat a transfer as one atomic database operation.
-
Data reconciliation: find a gap before making a decision
Use control totals, duplicate candidates, and relationship checks to test completeness.
-
Indexes, EXPLAIN, and the final report
Assemble the report, inspect its plan, add a justified index, and prove a backup by restoring it.