# Employee training system database schema

Source: https://personalsoftwarefactory.com/schemas/training-manual
Updated: 2026-12-05

> Sixteen tables. Subjects carry the design: a process or policy with an owner, a status, how many days people get to complete it, a verification interval and, for policies, the current version. Assignments are stored per person with their own due date, so a role assignment, assign_to_all and a re-signing policy version can each set due dates, and policy versions keep the exact text every signature points to through a two-column foreign key.

- 16 tables
- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1) on 2026-12-05
- 78 seed rows from the blueprint
- The blueprint's test build passed 15 of 15 acceptance checks

Files: [training-manual.sql](https://personalsoftwarefactory.com/schemas/training-manual.sql) · [training-manual-seed.sql](https://personalsoftwarefactory.com/schemas/training-manual-seed.sql) · [the Training Manual blueprint](https://personalsoftwarefactory.com/blueprints/training-manual)

## Relationships

- people.manager_id references people.id: each people row points to at most one another people row, and one people row can have many people rows pointing to it.
- person_roles.person_id references people.id: each person_roles row points to exactly one people row, and one people row can have many person_roles rows pointing to it.
- person_roles.role_id references roles.id: each person_roles row points to exactly one roles row, and one roles row can have many person_roles rows pointing to it.
- subjects.owner_id references people.id: each subjects row points to exactly one people row, and one people row can have many subjects rows pointing to it.
- subjects.verified_by references people.id: each subjects row points to at most one people row, and one people row can have many subjects rows pointing to it.
- steps.subject_id references subjects.id: each steps row points to exactly one subjects row, and one subjects row can have many steps rows pointing to it.
- questions.subject_id references subjects.id: each questions row points to exactly one subjects row, and one subjects row can have many questions rows pointing to it.
- question_options.question_id references questions.id: each question_options row points to exactly one questions row, and one questions row can have many question_options rows pointing to it.
- role_assignments.subject_id references subjects.id: each role_assignments row points to exactly one subjects row, and one subjects row can have many role_assignments rows pointing to it.
- role_assignments.role_id references roles.id: each role_assignments row points to exactly one roles row, and one roles row can have many role_assignments rows pointing to it.
- person_assignments.subject_id references subjects.id: each person_assignments row points to exactly one subjects row, and one subjects row can have many person_assignments rows pointing to it.
- person_assignments.person_id references people.id: each person_assignments row points to exactly one people row, and one people row can have many person_assignments rows pointing to it.
- step_reads.person_id references people.id: each step_reads row points to exactly one people row, and one people row can have many step_reads rows pointing to it.
- step_reads.step_id references steps.id: each step_reads row points to exactly one steps row, and one steps row can have many step_reads rows pointing to it.
- quiz_attempts.person_id references people.id: each quiz_attempts row points to exactly one people row, and one people row can have many quiz_attempts rows pointing to it.
- quiz_attempts.subject_id references subjects.id: each quiz_attempts row points to exactly one subjects row, and one subjects row can have many quiz_attempts rows pointing to it.
- policy_versions.subject_id references subjects.id: each policy_versions row points to exactly one subjects row, and one subjects row can have many policy_versions rows pointing to it.
- signatures.person_id references people.id: each signatures row points to exactly one people row, and one people row can have many signatures rows pointing to it.
- signatures.subject_id, version references policy_versions.subject_id, version: each signatures row points to exactly one policy_versions row, and one policy_versions row can have many signatures rows pointing to it.
- events.actor references people.id: each events row points to at most one people row, and one people row can have many events rows pointing to it.

## Tables

Also described as: training management database design, LMS database tables, policy acknowledgement data model.

### settings

The single row with the company name, time zone, due-soon days, verification default and email domain. Implements: Settings.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | INTEGER | no |  | Primary key | one row only Check: `id = 1` |
| `company_name` | TEXT | no |  |  |  |
| `time_zone` | TEXT | no |  |  | IANA name; due dates and verification days use it |
| `due_soon_days` | INTEGER | no | `2` |  | the due-soon reminder goes this many days before due_on (R8) |
| `verification_default_days` | INTEGER | no | `180` |  | default verify_every_days for new subjects |
| `email_domain` | TEXT | no |  |  | sign-in and new people must use it |

### people

Someone who works at the company, with their manager and start date. Implements: Person.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  | signatures must match it, ignoring case and extra spaces |
| `email` | TEXT | no |  | Unique | stored lowercase Check: `email = LOWER(email)` |
| `is_admin` | BOOLEAN | no | `FALSE` |  |  |
| `manager_id` | TEXT | yes |  | References people.id | a manager team is their direct reports only (R8) |
| `start_date` | DATE | no |  |  | people who start later are due start_date + due_days (R1) |
| `active` | BOOLEAN | no | `TRUE` |  |  |

- Table check: `manager_id IS NULL OR manager_id <> id`
- App rule (section 4): the last active admin cannot remove their own admin flag or deactivate themselves; manager chains cannot loop.

### roles

A job role, such as Barista. Implements: Role.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  | Unique |  |

### person_roles

A role a person holds. Implements: PersonRole.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `person_id` | TEXT | no |  | Primary key (part); References people.id |  |
| `role_id` | TEXT | no |  | Primary key (part); References roles.id |  |

### subjects

A process or policy, with its owner, status, due days, verification and version. Implements: Subject.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `title` | TEXT | no |  |  |  |
| `kind` | TEXT | no |  |  | Check: `kind IN ('process', 'policy')` |
| `owner_id` | TEXT | no |  | References people.id |  |
| `status` | TEXT | no | `'draft'` |  | Check: `status IN ('draft', 'published', 'archived')` |
| `assign_to_all` | BOOLEAN | no | `FALSE` |  | every active person |
| `open_to_everyone` | BOOLEAN | no | `FALSE` |  | readable by all, assigned or not |
| `due_days` | INTEGER | no |  |  | days to complete after assignment |
| `verify_every_days` | INTEGER | yes |  |  |  |
| `verified_at` | TIMESTAMP | yes |  |  |  |
| `verified_by` | TEXT | yes |  | References people.id |  |
| `version` | INTEGER | yes |  |  | policies only: the current published version Check: `version >= 1` |
| `pass_mark` | INTEGER | yes |  |  | percent, optional; only with a quiz Check: `pass_mark BETWEEN 0 AND 100` |

- Table check: `kind = 'policy' OR version IS NULL`
- App rule (R6): a published subject is due for verification on verified_at + verify_every_days, in the company time zone.
- App rule (section 4): only admins create subjects and choose the owner.

### steps

One step of a subject, in order, with soft deletion. Implements: Step.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `subject_id` | TEXT | no |  | References subjects.id |  |
| `position` | INTEGER | no |  |  |  |
| `title` | TEXT | no |  |  |  |
| `body` | TEXT | no |  |  | Markdown |
| `created_at` | TIMESTAMP | no |  |  | steps added later count as unread (R5) |
| `deleted_at` | TIMESTAMP | yes |  |  | reads of a deleted step stay in history under its title |

### questions

One multiple-choice quiz question and the position of its correct option. Implements: Question.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `subject_id` | TEXT | no |  | References subjects.id |  |
| `position` | INTEGER | no |  |  |  |
| `text` | TEXT | no |  |  |  |
| `correct_option` | INTEGER | no |  |  | the position of the correct option Check: `correct_option BETWEEN 1 AND 5` |

- App rule (section 5): a question has 2 to 5 options.

### question_options

One answer option of a question. Implements: child table of Question.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `question_id` | TEXT | no |  | Primary key (part); References questions.id |  |
| `position` | INTEGER | no |  | Primary key (part) | Check: `position BETWEEN 1 AND 5` |
| `text` | TEXT | no |  |  |  |

### role_assignments

A subject assigned to a role. Implements: RoleAssignment.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `subject_id` | TEXT | no |  | Primary key (part); References subjects.id |  |
| `role_id` | TEXT | no |  | Primary key (part); References roles.id |  |

### person_assignments

A subject assigned to one person, with its due date. Implements: PersonAssignment.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `subject_id` | TEXT | no |  | Primary key (part); References subjects.id |  |
| `person_id` | TEXT | no |  | Primary key (part); References people.id |  |
| `assigned_at` | TIMESTAMP | no |  |  |  |
| `due_on` | DATE | no |  |  | a calendar date in the company time zone; overdue from the day after |

- App rule (R1): due_on = assignment date + due_days, or start date + due_days for people who start later; changing due_days leaves existing due dates.
- App rule (section 7): a re-signing version moves due_on to publish date + due_days for people whose signature counted, if that is later.

### step_reads

A person reading a step, kept as an audit trail. Implements: StepRead.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `person_id` | TEXT | no |  | Primary key (part); References people.id |  |
| `step_id` | TEXT | no |  | Primary key (part); References steps.id |  |
| `read_at` | TIMESTAMP | no |  | Primary key (part) |  |

### quiz_attempts

One finished quiz attempt with its answers, score and result. Implements: QuizAttempt.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `subject_id` | TEXT | no |  | References subjects.id |  |
| `at` | TIMESTAMP | no |  |  |  |
| `answers` | TEXT | no |  |  | the chosen option position for each question, comma-separated in question order |
| `score_percent` | INTEGER | no |  |  | correct / questions, rounded down Check: `score_percent BETWEEN 0 AND 100` |
| `passed` | BOOLEAN | no |  |  | score_percent >= pass_mark, or any finished attempt when there is no pass mark |

### policy_versions

One published version of a policy with the text people signed. Implements: PolicyVersion.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `subject_id` | TEXT | no |  | Primary key (part); References subjects.id |  |
| `version` | INTEGER | no |  | Primary key (part) | Check: `version >= 1` |
| `published_at` | TIMESTAMP | no |  |  |  |
| `change_note` | TEXT | yes |  |  |  |
| `requires_resign` | BOOLEAN | no |  |  | everyone assigned must sign again |
| `body` | TEXT | no |  |  | the full text of the version steps, kept so every signature can show it |

### signatures

A person signing one version of a policy. Implements: Signature.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `subject_id` | TEXT | no |  |  |  |
| `version` | INTEGER | no |  |  |  |
| `typed_name` | TEXT | no |  |  |  |
| `signed_at` | TIMESTAMP | no |  |  |  |

- App rule (section 7): the typed name must match the person name, ignoring case and extra spaces; signing again while a signature counts is refused.

### events

One line of the append-only activity log. Implements: Event.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `at` | TIMESTAMP | no |  |  |  |
| `actor` | TEXT | yes |  | References people.id | NULL for the system |
| `type` | TEXT | no |  |  | the spec gives no fixed list |
| `data` | TEXT | yes |  |  | JSON text |

### notifications

One email in the outbox, with its send status. Implements: Notification.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `created_at` | TIMESTAMP | no |  |  |  |
| `kind` | TEXT | no |  |  | the spec gives no fixed list |
| `to_email` | TEXT | no |  |  |  |
| `subject` | TEXT | no |  |  |  |
| `body` | TEXT | no |  |  |  |
| `status` | TEXT | no | `'queued'` |  | Check: `status IN ('queued', 'sent', 'failed', 'logged')` |
| `error` | TEXT | yes |  |  |  |

## The SQL

```sql
-- Training Manual database schema
-- Source: https://personalsoftwarefactory.com/blueprints/training-manual (data model, section 5 of the blueprint)
-- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite). All timestamps are UTC.
-- License: MIT. Free to copy and adapt.

-- The single settings row for the company.
CREATE TABLE settings (
  id INTEGER PRIMARY KEY CHECK (id = 1), -- one row only
  company_name TEXT NOT NULL,
  time_zone TEXT NOT NULL, -- IANA name; due dates and verification days use it
  due_soon_days INTEGER NOT NULL DEFAULT 2, -- the due-soon reminder goes this many days before due_on (R8)
  verification_default_days INTEGER NOT NULL DEFAULT 180, -- default verify_every_days for new subjects
  email_domain TEXT NOT NULL -- sign-in and new people must use it
);

-- Someone who works at the company. An editor is anyone who owns a subject; there is no editor flag.
-- App rule (section 4): the last active admin cannot remove their own admin flag or deactivate themselves; manager chains cannot loop.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL, -- signatures must match it, ignoring case and extra spaces
  email TEXT NOT NULL UNIQUE CHECK (email = LOWER(email)), -- stored lowercase
  is_admin BOOLEAN NOT NULL DEFAULT FALSE,
  manager_id TEXT REFERENCES people(id), -- a manager team is their direct reports only (R8)
  start_date DATE NOT NULL, -- people who start later are due start_date + due_days (R1)
  active BOOLEAN NOT NULL DEFAULT TRUE,
  CHECK (manager_id IS NULL OR manager_id <> id)
);

-- A job role, such as Barista.
CREATE TABLE roles (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL UNIQUE
);

-- A role a person holds.
CREATE TABLE person_roles (
  person_id TEXT NOT NULL REFERENCES people(id),
  role_id TEXT NOT NULL REFERENCES roles(id),
  PRIMARY KEY (person_id, role_id)
);

-- A process or policy people are trained on.
-- App rule (R6): a published subject is due for verification on verified_at + verify_every_days, in the company time zone.
-- App rule (section 4): only admins create subjects and choose the owner.
CREATE TABLE subjects (
  id TEXT PRIMARY KEY,
  title TEXT NOT NULL,
  kind TEXT NOT NULL CHECK (kind IN ('process', 'policy')),
  owner_id TEXT NOT NULL REFERENCES people(id),
  status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'published', 'archived')),
  assign_to_all BOOLEAN NOT NULL DEFAULT FALSE, -- every active person
  open_to_everyone BOOLEAN NOT NULL DEFAULT FALSE, -- readable by all, assigned or not
  due_days INTEGER NOT NULL, -- days to complete after assignment
  verify_every_days INTEGER,
  verified_at TIMESTAMP,
  verified_by TEXT REFERENCES people(id),
  version INTEGER CHECK (version >= 1), -- policies only: the current published version
  pass_mark INTEGER CHECK (pass_mark BETWEEN 0 AND 100), -- percent, optional; only with a quiz
  CHECK (kind = 'policy' OR version IS NULL)
);

-- One step of a subject, in order. A deleted step leaves the reader and the progress count.
CREATE TABLE steps (
  id TEXT PRIMARY KEY,
  subject_id TEXT NOT NULL REFERENCES subjects(id),
  position INTEGER NOT NULL,
  title TEXT NOT NULL,
  body TEXT NOT NULL, -- Markdown
  created_at TIMESTAMP NOT NULL, -- steps added later count as unread (R5)
  deleted_at TIMESTAMP -- reads of a deleted step stay in history under its title
);

-- One multiple-choice quiz question of a subject.
-- App rule (section 5): a question has 2 to 5 options.
CREATE TABLE questions (
  id TEXT PRIMARY KEY,
  subject_id TEXT NOT NULL REFERENCES subjects(id),
  position INTEGER NOT NULL,
  text TEXT NOT NULL,
  correct_option INTEGER NOT NULL CHECK (correct_option BETWEEN 1 AND 5) -- the position of the correct option
);

-- One answer option of a question.
CREATE TABLE question_options (
  question_id TEXT NOT NULL REFERENCES questions(id),
  position INTEGER NOT NULL CHECK (position BETWEEN 1 AND 5),
  text TEXT NOT NULL,
  PRIMARY KEY (question_id, position)
);

-- A subject assigned to a role. Everyone with the role gets a person assignment, now and later (R1).
CREATE TABLE role_assignments (
  subject_id TEXT NOT NULL REFERENCES subjects(id),
  role_id TEXT NOT NULL REFERENCES roles(id),
  PRIMARY KEY (subject_id, role_id)
);

-- A subject assigned to one person, with the date it is due.
-- App rule (R1): due_on = assignment date + due_days, or start date + due_days for people who start later; changing due_days leaves existing due dates.
-- App rule (section 7): a re-signing version moves due_on to publish date + due_days for people whose signature counted, if that is later.
CREATE TABLE person_assignments (
  subject_id TEXT NOT NULL REFERENCES subjects(id),
  person_id TEXT NOT NULL REFERENCES people(id),
  assigned_at TIMESTAMP NOT NULL,
  due_on DATE NOT NULL, -- a calendar date in the company time zone; overdue from the day after
  PRIMARY KEY (subject_id, person_id)
);

-- A person reading a step. Append-only (R9).
CREATE TABLE step_reads (
  person_id TEXT NOT NULL REFERENCES people(id),
  step_id TEXT NOT NULL REFERENCES steps(id),
  read_at TIMESTAMP NOT NULL,
  PRIMARY KEY (person_id, step_id, read_at)
);

-- One finished quiz attempt. Append-only (R9); the best score counts.
CREATE TABLE quiz_attempts (
  id TEXT PRIMARY KEY,
  person_id TEXT NOT NULL REFERENCES people(id),
  subject_id TEXT NOT NULL REFERENCES subjects(id),
  at TIMESTAMP NOT NULL,
  answers TEXT NOT NULL, -- the chosen option position for each question, comma-separated in question order
  score_percent INTEGER NOT NULL CHECK (score_percent BETWEEN 0 AND 100), -- correct / questions, rounded down
  passed BOOLEAN NOT NULL -- score_percent >= pass_mark, or any finished attempt when there is no pass mark
);

-- One published version of a policy, with the text people signed.
CREATE TABLE policy_versions (
  subject_id TEXT NOT NULL REFERENCES subjects(id),
  version INTEGER NOT NULL CHECK (version >= 1),
  published_at TIMESTAMP NOT NULL,
  change_note TEXT,
  requires_resign BOOLEAN NOT NULL, -- everyone assigned must sign again
  body TEXT NOT NULL, -- the full text of the version steps, kept so every signature can show it
  PRIMARY KEY (subject_id, version)
);

-- A person signing one version of a policy. Never edited or deleted (R4).
-- App rule (section 7): the typed name must match the person name, ignoring case and extra spaces; signing again while a signature counts is refused.
CREATE TABLE signatures (
  id TEXT PRIMARY KEY,
  person_id TEXT NOT NULL REFERENCES people(id),
  subject_id TEXT NOT NULL,
  version INTEGER NOT NULL,
  typed_name TEXT NOT NULL,
  signed_at TIMESTAMP NOT NULL,
  FOREIGN KEY (subject_id, version) REFERENCES policy_versions(subject_id, version)
);

-- One line of the append-only activity log. An export also writes one, with its filters and row count (R10).
CREATE TABLE events (
  id TEXT PRIMARY KEY,
  at TIMESTAMP NOT NULL,
  actor TEXT REFERENCES people(id), -- NULL for the system
  type TEXT NOT NULL, -- the spec gives no fixed list
  data TEXT -- JSON text
);

-- One email in the outbox, listed newest first.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  created_at TIMESTAMP NOT NULL,
  kind TEXT NOT NULL, -- the spec gives no fixed list
  to_email TEXT NOT NULL,
  subject TEXT NOT NULL,
  body TEXT NOT NULL,
  status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'failed', 'logged')),
  error TEXT
);
```

## Seed data

Loads the settings row, 6 people, 3 roles and 5 role memberships, the 5 published subjects with their 18 steps, the 5-question Espresso basics quiz with its 15 options, 5 role assignments and 15 person assignments. Dates without a time use 12:00 UTC. Placeholders: step body (the spec gives step titles only) and step created_at (2026-01-01); start_date 2026-01-01 for everyone except Eli Moss; assigned_at 2026-09-01 for the Opening checklist (Cara, Dev, Ben), Cash handling (Ben) and Roasting safety (Fay), with due_on following R1 from it, except Cash handling, which version 3 (published Oct 14 with requires_resign) moves to Oct 21. verified_at is left empty for Espresso basics, Food safety and Cash handling, which the spec says only were verified within the last 60 days; verify_every_days is the 180-day default where no interval is given; verified_by is empty. Left out: step reads, quiz attempts and signatures, because the spec gives no read, attempt or signing times, does not say which 2 steps Eli read or which questions Cara and Dev missed; policy versions, because 4 of 5 publish dates, every version text and whether Food safety version 2 required re-signing are not given; and events and notifications, which the spec does not seed. Without them, progress statuses from section 6 cannot be computed on this seed.

## Load it

```sh
# SQLite
curl -s https://personalsoftwarefactory.com/schemas/training-manual.sql https://personalsoftwarefactory.com/schemas/training-manual-seed.sql | sqlite3 training_manual.db
# PostgreSQL
createdb training_manual && curl -s https://personalsoftwarefactory.com/schemas/training-manual.sql https://personalsoftwarefactory.com/schemas/training-manual-seed.sql | psql -v ON_ERROR_STOP=1 training_manual
```

## Design decisions

### Assignments are stored per person, with their own due date

R1 assigns a role subject to everyone with the role, now and later, and keeps existing assignments when a role assignment is removed. So role_assignments records the rule and person_assignments the result, one row per subject and person with assigned_at and due_on. Section 7 can move one person's due date when a re-signing version is published, which a computed due date could not do.

### Signatures point at the exact policy version

Section 7 says every signature shows the exact text of the version signed. policy_versions keeps each published version's full text, keyed by subject and version, and signatures has a two-column foreign key to it, so a signature can never name a version that was not published. Signatures, step reads and quiz attempts are append-only (R9).

### Quiz options are a child table, the answer is a position

Section 5 gives each question 2 to 5 options and a correct option. Options are a child table keyed by question and position (1 to 5), and correct_option stores the position, so renaming an option does not break the answer key. The 2-option minimum counts rows, so it is an app rule.

### Version only on policies

Section 5 gives subjects a version for policies. A CHECK keeps version empty on processes and at least 1 on policies that have one; publishing a policy for the first time makes it version 1 (section 7). pass_mark is an optional percent from 0 to 100.

### Steps are soft-deleted

Section 5 says a deleted step leaves the reader and the progress count, but its reads stay in history under its title. deleted_at marks it instead of removing the row, so step_reads keeps a valid foreign key and the training record stays an audit trail. created_at lets the app count steps added later as unread (R5).

### Progress is computed, not stored

Section 6 derives a status (Completed, Overdue, Needs signature, In progress, Not started) and a percent from reads, attempts and signatures, the same way everywhere (R2). There is no status column on person_assignments, because a re-signing version or a new step changes it without anyone touching the assignment.

## Example queries

### Subjects due for verification on Oct 15 (180-day interval)

```sql
SELECT s.title, o.name AS owner, s.verified_at FROM subjects s JOIN people o ON o.id = s.owner_id WHERE s.status = 'published' AND s.verify_every_days = 180 AND s.verified_at < '2026-04-19 04:00:00' ORDER BY s.verified_at;
```

On the seed data: 1 row, Opening checklist (owner Ben Ortiz, verified 2026-04-10).

### Quiz answer key, shown after a pass

```sql
SELECT q.position, q.text AS question, o.text AS correct_answer FROM questions q JOIN question_options o ON o.question_id = q.id AND o.position = q.correct_option WHERE q.subject_id = 's_espresso' ORDER BY q.position;
```

On the seed data: 5 rows, from 18 g to Before and after every jug.

### One person's assignments with due dates

```sql
SELECT s.title, s.kind, pa.assigned_at, pa.due_on FROM person_assignments pa JOIN subjects s ON s.id = pa.subject_id WHERE pa.person_id = 'p_eli' ORDER BY pa.due_on, s.title;
```

On the seed data: 3 rows for Eli Moss, Opening checklist due 2026-10-19 first.

### People assigned to each subject

```sql
SELECT s.title, s.kind, COUNT(pa.person_id) AS assigned FROM subjects s LEFT JOIN person_assignments pa ON pa.subject_id = s.id WHERE s.status = 'published' GROUP BY s.title, s.kind ORDER BY s.title;
```

On the seed data: 5 rows; Food safety policy has 6 (assign_to_all).

## What was not tested

- MySQL, MariaDB, SQL Server and Oracle. The file avoids engine-specific syntax, but it was not run on them.
- Other versions of SQLite and PostgreSQL than the two named above.
- PostgreSQL as a server. The PostgreSQL run used PGlite, which is PostgreSQL compiled to run in-process.
- Production load. The check loads the seed rows and runs the example queries; it says nothing about performance with real volumes.
- Migrations. This is a schema for a new database, not a path from an existing one.

## The blueprint

This schema is section 5 of the [Training Manual blueprint](https://personalsoftwarefactory.com/blueprints/training-manual), which also has the business rules, the screens, the phased build prompts and the acceptance checks. Paste-ready spec: https://personalsoftwarefactory.com/blueprints/training-manual/blueprint.md
