MiniCTRMSearch

MiniCTRM - Build Tutorial 642: What a relational database does: tables, keys, constraints, triggers and where business rules belong

→ to begin · N for the speaker notes

On a phone: Next or a swipe left to begin, Notes for the words.

What you'll learn

An inventory of every part of your database beyond tables and columns, the rule for where a business rule lives written down and held by a test, every business limit enforced in the service that every write path goes through, the database kept to structure, and a portability check against a second database.

  • What a schema collects – Business rules nobody designed, where they come from, and the rule MiniCTRM keeps.
  • What you need first – The three lessons this one builds on, and where in a build to take it.
  • A database is more than tables and columns – Every part of a database, what it is, and whether it is plumbing or business; and SQLite's loose types.
  • Where a rule belongs – The visibility test, what goes where, and the hard parts.
  • An inventory of your database – Every part of your schema listed from the live database, with counts, kept current by a test.
  • The rule, written and tested – An ADR, four lines in CLAUDE.md, and a test that catches a new CHECK rule or trigger.
  • Every limit in the service – One check per limit where every write path passes, the same message on each.
  • A portability check – The tests on a second database in the comprehensive tier, dialect SQL behind one adapter, quiet differences pinned.
  • Ship it – /ship, with the inventory, the schema test and the write-path test among the rest.
  • How MiniCTRM did it – The SQL Query screen and the Data Model: what a user can see of a database.

Before you start

The lessons this one builds on: 514 Choosing the database: SQLite first, PostgreSQL later; migrations only, 522 Designing the deal model: how to tell Claude what you want, 632 Robustness: transactions, one door per write, validation, retries, the activity log.

Copyright 2026-2027 Brian Shydlo. MiniCTRM is source-available under the PolyForm Strict License 1.0.0 (https://polyformproject.org/licenses/strict/1.0.0): free for learning and other noncommercial use; no changes and no redistribution; commercial use needs permission.

Welcome

What a relational database is

1 / 15
What a relational database is
What a schema collects

Rules nobody designed

2 / 15
Rules nobody designed
What you need first

What you need first

3 / 15
What you need first
A database is more than tables and columns

A database is more than tables and columns

4 / 15
A database is more than tables and columns
A database is more than tables and columns

SQLite does not enforce types

5 / 15
SQLite does not enforce types
Where a rule belongs

Where a rule belongs

6 / 15
Where a rule belongs
Where a rule belongs

The hard parts

7 / 15
The hard parts
An inventory of your database

An inventory of your database

8 / 15
An inventory of your database
The rule, written and tested

The rule, written and tested

9 / 15
The rule, written and tested
Every limit in the service

Every limit in the service, every path covered

10 / 15
Every limit in the service, every path covered
A portability check

A portability check

11 / 15
A portability check
Ship it

Ship it

12 / 15
Ship it
How MiniCTRM did it

The SQL Query screen

13 / 15
The SQL Query screen
How MiniCTRM did it

The Data Model

14 / 15
The Data Model
What you have now

What you have now

15 / 15
What you have now

You have finished lesson 642, What a relational database does: tables, keys, constraints, triggers and where business rules belong.

Where next?

← → move · N notes · Home / End