# Resource planning system database schema

Source: https://personalsoftwarefactory.com/schemas/capacity-planner
Updated: 2026-12-04

> Nine tables, and no table of totals: capacity, booked hours, utilization and budget use are computed from the rows every time. bookings carries the design, with one row per person, phase and run of whole weeks, at so many minutes a day or a week, and a CHECK that ties the allowed range to that unit. people holds working hours as seven per-weekday minute columns, and holidays and time off reduce them day by day in the app.

- 9 tables, 5 indexes
- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1) on 2026-12-04
- 66 seed rows from the blueprint
- The blueprint's test build passed 33 of 33 acceptance checks

Files: [capacity-planner.sql](https://personalsoftwarefactory.com/schemas/capacity-planner.sql) · [capacity-planner-seed.sql](https://personalsoftwarefactory.com/schemas/capacity-planner-seed.sql) · [the Capacity Planner blueprint](https://personalsoftwarefactory.com/blueprints/capacity-planner)

## Relationships

- person_skills.person_id references people.id: each person_skills row points to exactly one people row, and one people row can have many person_skills rows pointing to it.
- person_skills.skill_id references skills.id: each person_skills row points to exactly one skills row, and one skills row can have many person_skills rows pointing to it. On delete: cascade.
- time_off_entries.person_id references people.id: each time_off_entries row points to exactly one people row, and one people row can have many time_off_entries rows pointing to it.
- time_off_entries.created_by references people.id: each time_off_entries row points to exactly one people row, and one people row can have many time_off_entries rows pointing to it.
- projects.created_by references people.id: each projects row points to exactly one people row, and one people row can have many projects rows pointing to it.
- projects.status_changed_by references people.id: each projects row points to at most one people row, and one people row can have many projects rows pointing to it.
- phases.project_id references projects.id: each phases row points to exactly one projects row, and one projects row can have many phases rows pointing to it.
- bookings.person_id references people.id: each bookings row points to exactly one people row, and one people row can have many bookings rows pointing to it.
- bookings.phase_id references phases.id: each bookings row points to exactly one phases row, and one phases row can have many bookings rows pointing to it.
- bookings.created_by references people.id: each bookings row points to exactly one people row, and one people row can have many bookings rows pointing to it.
- bookings.updated_by references people.id: each bookings row points to exactly one people row, and one people row can have many bookings rows pointing to it.
- notifications.recipient_id references people.id: each notifications row points to exactly one people row, and one people row can have many notifications rows pointing to it.

## Tables

Also described as: resource scheduling database design, capacity planning database tables, project allocation schema.

### people

Someone who can sign in, with a role, whether they are on the schedule, and working minutes for each weekday. Implements: Person.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  | Check: `length(name) BETWEEN 1 AND 80` |
| `email` | TEXT | no |  | Unique | stored lower-case; any name@domain address |
| `title` | TEXT | yes |  |  | optional, such as "Designer" Check: `length(title) <= 60` |
| `role` | TEXT | no | `'member'` |  | Check: `role IN ('admin', 'planner', 'member')` |
| `on_schedule` | BOOLEAN | no | `TRUE` |  | FALSE for people who take no project work |
| `mon_minutes` | INTEGER | no | `480` |  | Check: `mon_minutes BETWEEN 0 AND 1440 AND mon_minutes % 15 = 0` |
| `tue_minutes` | INTEGER | no | `480` |  | Check: `tue_minutes BETWEEN 0 AND 1440 AND tue_minutes % 15 = 0` |
| `wed_minutes` | INTEGER | no | `480` |  | Check: `wed_minutes BETWEEN 0 AND 1440 AND wed_minutes % 15 = 0` |
| `thu_minutes` | INTEGER | no | `480` |  | Check: `thu_minutes BETWEEN 0 AND 1440 AND thu_minutes % 15 = 0` |
| `fri_minutes` | INTEGER | no | `480` |  | Check: `fri_minutes BETWEEN 0 AND 1440 AND fri_minutes % 15 = 0` |
| `sat_minutes` | INTEGER | no | `0` |  | Check: `sat_minutes BETWEEN 0 AND 1440 AND sat_minutes % 15 = 0` |
| `sun_minutes` | INTEGER | no | `0` |  | Check: `sun_minutes BETWEEN 0 AND 1440 AND sun_minutes % 15 = 0` |
| `active` | BOOLEAN | no | `TRUE` |  |  |
| `created_at` | TIMESTAMP | no |  |  |  |

- Table check: `email = lower(email)`
- Table check: `on_schedule = FALSE OR mon_minutes + tue_minutes + wed_minutes + thu_minutes + fri_minutes + sat_minutes + sun_minutes > 0`
- App rule (R8): at least one active admin; deactivating or taking someone off the schedule is refused while they have bookings that run this week or later.

### skills

A skill used to search for people who have time. Implements: Skill.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  | Check: `length(name) BETWEEN 1 AND 40` |

- Unique index `skills_name_unique` on (lower(name)). Skill names are unique ignoring case.

### person_skills

One skill a person has. Implements: PersonSkill.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `person_id` | TEXT | no |  | Primary key (part); References people.id |  |
| `skill_id` | TEXT | no |  | Primary key (part); References skills.id, on delete cascade |  |

### holidays

A company holiday on one date, which gives everyone 0 capacity that day. Implements: Holiday.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `date` | DATE | no |  | Unique | one holiday per date |
| `name` | TEXT | no |  |  | Check: `length(name) BETWEEN 1 AND 60` |

### time_off_entries

A recorded run of days off for one person, full days or a part day on each working day. Implements: TimeOff.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `start_date` | DATE | no |  |  |  |
| `end_date` | DATE | no |  |  |  |
| `part_day_minutes` | INTEGER | yes |  |  | NULL means full days Check: `part_day_minutes BETWEEN 15 AND 1440 AND part_day_minutes % 15 = 0` |
| `created_by` | TEXT | no |  | References people.id |  |
| `created_at` | TIMESTAMP | no |  |  |  |

- Table check: `end_date >= start_date`
- App rule (R7): at most 366 days in total; a person's time off cannot overlap their other time off.

### projects

A project, tentative, confirmed, closed or lost, with who changed its status and when. Implements: Project.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  | Check: `length(name) BETWEEN 1 AND 80` |
| `client` | TEXT | yes |  |  | optional Check: `length(client) <= 80` |
| `status` | TEXT | no |  |  | Check: `status IN ('tentative', 'confirmed', 'closed', 'lost')` |
| `created_by` | TEXT | no |  | References people.id |  |
| `created_at` | TIMESTAMP | no |  |  |  |
| `status_changed_by` | TEXT | yes |  | References people.id | set by Confirm, Mark lost and Close |
| `status_changed_at` | TIMESTAMP | yes |  |  |  |

- Table check: `(status_changed_by IS NULL) = (status_changed_at IS NULL)`
- Table check: `status <> 'tentative' OR status_changed_at IS NULL`
- Table check: `status NOT IN ('closed', 'lost') OR status_changed_at IS NOT NULL`
- Unique index `projects_name_unique` on (lower(name)). Project names are unique ignoring case.
- App rule (section 7): tentative > confirmed > closed, or tentative > lost.

### phases

A phase of a project with an optional budget in whole hours, stored as minutes. Implements: Phase.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `project_id` | TEXT | no |  | References projects.id |  |
| `name` | TEXT | no |  |  | Check: `length(name) BETWEEN 1 AND 60` |
| `budget_minutes` | INTEGER | yes |  |  | NULL means no budget; whole hours 1 to 100,000 Check: `budget_minutes BETWEEN 60 AND 6000000 AND budget_minutes % 60 = 0` |
| `position` | INTEGER | no |  |  | display order within the project |
| `created_at` | TIMESTAMP | no |  |  |  |

- Unique index `phases_name_unique` on (project_id, lower(name)). Phase names are unique within a project ignoring case.
- App rule (R10): a project keeps at least one phase; a phase with bookings cannot be deleted.

### bookings

One person booked on one phase from a first to a last week, at so many minutes a day or a week. Implements: Booking.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `phase_id` | TEXT | no |  | References phases.id | the booking's project is its phase's project |
| `first_week` | DATE | no |  |  | a Monday |
| `last_week` | DATE | no |  |  | a Monday, on or after first_week |
| `unit` | TEXT | no |  |  | Check: `unit IN ('per_day', 'per_week')` |
| `minutes` | INTEGER | no |  |  | per_day: 15 to 1440; per_week: 15 to 10080; multiples of 15 |
| `tentative` | BOOLEAN | no |  |  |  |
| `note` | TEXT | yes |  |  | Check: `length(note) <= 200` |
| `created_by` | TEXT | no |  | References people.id |  |
| `created_at` | TIMESTAMP | no |  |  |  |
| `updated_by` | TEXT | no |  | References people.id |  |
| `updated_at` | TIMESTAMP | no |  |  |  |

- Table check: `last_week >= first_week`
- Table check: `minutes % 15 = 0 AND ((unit = 'per_day' AND minutes BETWEEN 15 AND 1440) OR (unit = 'per_week' AND minutes BETWEEN 15 AND 10080))`
- Index `bookings_person_weeks` on (person_id, first_week, last_week)
- Index `bookings_phase` on (phase_id)
- App rule (R2): first_week and last_week are Mondays and cover at most 52 weeks, both ends counted.
- App rule (R4, R5): only active people on the schedule; on a tentative project every booking is tentative; closed and lost projects' bookings never change.
- App rule (R12): a save carries the updated_at it loaded and is refused if the row changed since.

### notifications

A notification to one person in the outbox, with its kind, status and send attempts. Implements: Notification.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `recipient_id` | TEXT | no |  | References people.id |  |
| `kind` | TEXT | no |  |  | Check: `kind IN ('over_capacity', 'booking_added', 'booking_changed', 'booking_removed', 'project_confirmed', 'time_off_added', 'time_off_removed')` |
| `subject` | TEXT | no |  |  |  |
| `body` | TEXT | no |  |  | plain text |
| `status` | TEXT | no | `'queued'` |  | logged when no provider is configured Check: `status IN ('queued', 'sent', 'logged', 'failed')` |
| `attempts` | INTEGER | no | `0` |  | each send attempt adds 1; logging counts as one Check: `attempts >= 0` |
| `error` | TEXT | yes |  |  |  |
| `created_at` | TIMESTAMP | no |  |  |  |
| `sent_at` | TIMESTAMP | yes |  |  |  |

## The SQL

```sql
-- Capacity Planner database schema
-- Source: https://personalsoftwarefactory.com/blueprints/capacity-planner (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.
-- Every hour amount is integer minutes (1 hour = 60). Dates are calendar dates in the team time zone.
-- There is no table of totals: capacity, booked and free hours, utilization and budget use are computed every time (R11).

-- A person who can sign in, with a role and working hours per weekday. Deactivated, never deleted.
-- App rule (R8): at least one active admin; deactivating or taking someone off the schedule is refused while they have bookings that run this week or later.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 80),
  email TEXT NOT NULL UNIQUE, -- stored lower-case; any name@domain address
  title TEXT CHECK (length(title) <= 60), -- optional, such as "Designer"
  role TEXT NOT NULL DEFAULT 'member' CHECK (role IN ('admin', 'planner', 'member')),
  on_schedule BOOLEAN NOT NULL DEFAULT TRUE, -- FALSE for people who take no project work
  mon_minutes INTEGER NOT NULL DEFAULT 480 CHECK (mon_minutes BETWEEN 0 AND 1440 AND mon_minutes % 15 = 0),
  tue_minutes INTEGER NOT NULL DEFAULT 480 CHECK (tue_minutes BETWEEN 0 AND 1440 AND tue_minutes % 15 = 0),
  wed_minutes INTEGER NOT NULL DEFAULT 480 CHECK (wed_minutes BETWEEN 0 AND 1440 AND wed_minutes % 15 = 0),
  thu_minutes INTEGER NOT NULL DEFAULT 480 CHECK (thu_minutes BETWEEN 0 AND 1440 AND thu_minutes % 15 = 0),
  fri_minutes INTEGER NOT NULL DEFAULT 480 CHECK (fri_minutes BETWEEN 0 AND 1440 AND fri_minutes % 15 = 0),
  sat_minutes INTEGER NOT NULL DEFAULT 0 CHECK (sat_minutes BETWEEN 0 AND 1440 AND sat_minutes % 15 = 0),
  sun_minutes INTEGER NOT NULL DEFAULT 0 CHECK (sun_minutes BETWEEN 0 AND 1440 AND sun_minutes % 15 = 0),
  active BOOLEAN NOT NULL DEFAULT TRUE,
  created_at TIMESTAMP NOT NULL,
  CHECK (email = lower(email)),
  -- R8: someone on the schedule needs at least one working day
  CHECK (on_schedule = FALSE OR mon_minutes + tue_minutes + wed_minutes + thu_minutes + fri_minutes + sat_minutes + sun_minutes > 0)
);

-- A skill used to search Who has time.
CREATE TABLE skills (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 40)
);

-- Skill names are unique ignoring case.
CREATE UNIQUE INDEX skills_name_unique ON skills (lower(name));

-- One skill a person has. Deleting a skill removes it from everyone (R9).
CREATE TABLE person_skills (
  person_id TEXT NOT NULL REFERENCES people(id),
  skill_id TEXT NOT NULL REFERENCES skills(id) ON DELETE CASCADE,
  PRIMARY KEY (person_id, skill_id)
);

-- A company holiday that applies to everyone: capacity 0 that day. Added and deleted, never renamed.
CREATE TABLE holidays (
  id TEXT PRIMARY KEY,
  date DATE NOT NULL UNIQUE, -- one holiday per date
  name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 60)
);

-- Recorded time off for one person, full days or a part day on each working day in the range. Never edited.
-- App rule (R7): at most 366 days in total; a person's time off cannot overlap their other time off.
CREATE TABLE time_off_entries (
  id TEXT PRIMARY KEY,
  person_id TEXT NOT NULL REFERENCES people(id),
  start_date DATE NOT NULL,
  end_date DATE NOT NULL,
  part_day_minutes INTEGER CHECK (part_day_minutes BETWEEN 15 AND 1440 AND part_day_minutes % 15 = 0), -- NULL means full days
  created_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL,
  CHECK (end_date >= start_date)
);

-- A client or internal project. Closed and lost are final: nothing about the project, its phases or bookings changes after (R5).
-- App rule (section 7): tentative > confirmed > closed, or tentative > lost.
CREATE TABLE projects (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 80),
  client TEXT CHECK (length(client) <= 80), -- optional
  status TEXT NOT NULL CHECK (status IN ('tentative', 'confirmed', 'closed', 'lost')),
  created_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL,
  status_changed_by TEXT REFERENCES people(id), -- set by Confirm, Mark lost and Close
  status_changed_at TIMESTAMP,
  CHECK ((status_changed_by IS NULL) = (status_changed_at IS NULL)),
  CHECK (status <> 'tentative' OR status_changed_at IS NULL),
  CHECK (status NOT IN ('closed', 'lost') OR status_changed_at IS NOT NULL)
);

-- Project names are unique ignoring case.
CREATE UNIQUE INDEX projects_name_unique ON projects (lower(name));

-- A phase of a project. Every booking belongs to one phase, so every booked hour counts against exactly one budget.
-- App rule (R10): a project keeps at least one phase; a phase with bookings cannot be deleted.
CREATE TABLE phases (
  id TEXT PRIMARY KEY,
  project_id TEXT NOT NULL REFERENCES projects(id),
  name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 60),
  budget_minutes INTEGER CHECK (budget_minutes BETWEEN 60 AND 6000000 AND budget_minutes % 60 = 0), -- NULL means no budget; whole hours 1 to 100,000
  position INTEGER NOT NULL, -- display order within the project
  created_at TIMESTAMP NOT NULL
);

-- Phase names are unique within a project ignoring case.
CREATE UNIQUE INDEX phases_name_unique ON phases (project_id, lower(name));

-- One person booked on one phase for a run of whole weeks, at so many minutes a day or a week (Float calls this an allocation).
-- App rule (R2): first_week and last_week are Mondays and cover at most 52 weeks, both ends counted.
-- App rule (R4, R5): only active people on the schedule; on a tentative project every booking is tentative; closed and lost projects' bookings never change.
-- App rule (R12): a save carries the updated_at it loaded and is refused if the row changed since.
CREATE TABLE bookings (
  id TEXT PRIMARY KEY,
  person_id TEXT NOT NULL REFERENCES people(id),
  phase_id TEXT NOT NULL REFERENCES phases(id), -- the booking's project is its phase's project
  first_week DATE NOT NULL, -- a Monday
  last_week DATE NOT NULL, -- a Monday, on or after first_week
  unit TEXT NOT NULL CHECK (unit IN ('per_day', 'per_week')),
  minutes INTEGER NOT NULL, -- per_day: 15 to 1440; per_week: 15 to 10080; multiples of 15
  tentative BOOLEAN NOT NULL,
  note TEXT CHECK (length(note) <= 200),
  created_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL,
  updated_by TEXT NOT NULL REFERENCES people(id),
  updated_at TIMESTAMP NOT NULL,
  CHECK (last_week >= first_week),
  CHECK (minutes % 15 = 0 AND ((unit = 'per_day' AND minutes BETWEEN 15 AND 1440) OR (unit = 'per_week' AND minutes BETWEEN 15 AND 10080)))
);

CREATE INDEX bookings_person_weeks ON bookings (person_id, first_week, last_week);
CREATE INDEX bookings_phase ON bookings (phase_id);

-- A notification in the outbox, written in the same transaction as the change and sent after it commits.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  recipient_id TEXT NOT NULL REFERENCES people(id),
  kind TEXT NOT NULL CHECK (kind IN ('over_capacity', 'booking_added', 'booking_changed', 'booking_removed', 'project_confirmed', 'time_off_added', 'time_off_removed')),
  subject TEXT NOT NULL,
  body TEXT NOT NULL, -- plain text
  status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'logged', 'failed')), -- logged when no provider is configured
  attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0), -- each send attempt adds 1; logging counts as one
  error TEXT,
  created_at TIMESTAMP NOT NULL,
  sent_at TIMESTAMP
);
```

## Seed data

Loads all of section 14 for Larkspur Studio: 9 people with their working hours, 8 skills with 13 person-skill links, 4 holidays, 5 time off entries, 5 projects (Pinecrest campaign lost by Ana Lima at 2026-11-12 15:00 UTC), 7 phases and the 15 bookings. Every row is stamped as created by Ana Lima at 2026-10-26 14:00 UTC, as the spec says. Phase positions are 1 and 2 in the order the spec lists them. The outbox starts empty. Computed from these rows, every phase's confirmed and tentative hours and every cell of the section 14 Schedule (for example Lee Park 40/36 in the week of 16 Nov) match the spec.

## Load it

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

## Design decisions

### Nothing is totaled in the database

R11 says every number in sections 6 to 8 (capacity, booked and free hours, utilization, budget left and used) is computed from the rows each time by the same server-side functions, and section 5 says there is no table of totals. So the schema has none, and no stored column depends on another row. A cached total would drift the moment a holiday, time off or someone's working hours changed, because those change past weeks too.

### Bookings store a unit and minutes, checked together

Section 5 books whole weeks at per_day or per_week minutes, in multiples of 15, from 15 to 1440 a day or 15 to 10080 a week (R3). One CHECK ties the range to the unit, so 30 hours a day is refused while 30 hours a week is allowed. The unit matters for capacity: section 6 shrinks a per-day booking by holidays and full days off, while a per-week booking keeps its hours, which is how Ben's week of 23 Nov goes Over.

### Working hours are seven columns, with one working day required

Person holds mon_minutes to sun_minutes, 0 to 1440 in multiples of 15, defaulting to 480 on weekdays and 0 at the weekend (section 5). R8 says someone on the schedule needs at least one working day; that fits in one row, so it is a CHECK that the seven columns add up to more than 0 whenever on_schedule is true.

### Names are unique ignoring case through expression indexes

Skill and project names are unique ignoring case, and phase names are unique within their project ignoring case (R9, R10). Unique indexes on lower(name), and on (project_id, lower(name)) for phases, enforce this on both engines. The build test found the spec didn't say whether renaming a project or phase to its own name in another case was allowed; it is, and these indexes allow it because a row never clashes with itself. (This point comes from a gap the blueprint's build test found.)

### Status stamps follow the project's lifecycle

Section 7 sets status_changed_by and status_changed_at on Confirm, Mark lost and Close, and only those. CHECKs keep the pair set together, empty while a project is tentative, and present on every closed or lost project. A project created as confirmed has no stamp, which is how the seed's confirmed projects load.

### Deleting a skill removes it from everyone

R9 deletes a skill after asking "Remove Illustration from 1 person?" and then removes it from everyone who has it, active or not. The foreign key from person_skills to skills is ON DELETE CASCADE so that happens in the same statement. Other foreign keys have no cascade, because people are deactivated rather than deleted and a phase with bookings cannot be deleted (R10).

### Week and range rules that need date arithmetic stay in the app

first_week and last_week must be Mondays, a booking covers at most 52 weeks and time off at most 366 days (R2, R7). Portable SQL has no shared date functions, so the database checks only that the last week or day is not before the first, and the app checks the rest. The build test found "at most 52 weeks" didn't say whether both ends count; they do, so 16 Nov 2026 to 8 Nov 2027 is allowed. (This point comes from a gap the blueprint's build test found.)

## Example queries

### Bookings that count in the week of 23 Nov

```sql
SELECT pe.name AS person, pr.name AS project, ph.name AS phase, b.unit, b.minutes, CASE WHEN b.tentative THEN 'tentative' ELSE 'confirmed' END AS kind FROM bookings b JOIN people pe ON pe.id = b.person_id JOIN phases ph ON ph.id = b.phase_id JOIN projects pr ON pr.id = ph.project_id WHERE b.first_week <= '2026-11-23' AND b.last_week >= '2026-11-23' AND pr.status <> 'lost' ORDER BY pe.name, pr.name, ph.position;
```

On the seed data: 7 rows, including Ben Cho on Brightline website (Build) at 1440 minutes per_week, confirmed, and on Studio website (Refresh) at 480, which together make his 32 h week against 24 h of capacity.

### Project budgets

```sql
SELECT pr.name AS project, pr.status, SUM(ph.budget_minutes) / 60 AS budget_hours, COUNT(ph.id) AS phases FROM projects pr JOIN phases ph ON ph.project_id = pr.id GROUP BY pr.name, pr.status ORDER BY pr.name;
```

On the seed data: 5 rows (Brightline website, confirmed, 530 h over 2 phases; Studio website has no budget, so budget_hours is NULL).

### Who blocks deactivation (R8): bookings that run this week or later

```sql
SELECT pe.name, COUNT(*) AS bookings FROM bookings b JOIN people pe ON pe.id = b.person_id JOIN phases ph ON ph.id = b.phase_id JOIN projects pr ON pr.id = ph.project_id WHERE b.last_week >= '2026-11-16' AND pr.status IN ('tentative', 'confirmed') GROUP BY pe.name ORDER BY pe.name;
```

On the seed data: 7 rows, including Ben Cho 2 and Lee Park 1, the counts in R8's messages; Tom Bennett's only booking ended before the current week.

### People with a skill, for Who has time

```sql
SELECT pe.name, pe.mon_minutes + pe.tue_minutes + pe.wed_minutes + pe.thu_minutes + pe.fri_minutes + pe.sat_minutes + pe.sun_minutes AS weekly_minutes FROM people pe JOIN person_skills ps ON ps.person_id = pe.id JOIN skills s ON s.id = ps.skill_id WHERE s.name = 'UI design' AND pe.active = TRUE AND pe.on_schedule = TRUE ORDER BY pe.name;
```

On the seed data: 2 rows (Jo Park 1440 minutes a week, Maya Chen 2400).

### Time off overlapping the week of 23 Nov

```sql
SELECT pe.name, t.start_date, t.end_date, t.part_day_minutes FROM time_off_entries t JOIN people pe ON pe.id = t.person_id WHERE t.start_date <= '2026-11-29' AND t.end_date >= '2026-11-23' ORDER BY t.start_date, pe.name;
```

On the seed data: 2 rows (Maya Chen, 2026-11-23 to 2026-11-25, full days; Priya Nair, 2026-11-25 to 2026-11-27).

## 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 [Capacity Planner blueprint](https://personalsoftwarefactory.com/blueprints/capacity-planner), which also has the business rules, the screens, the phased build prompts and the acceptance checks. Paste-ready spec: https://personalsoftwarefactory.com/blueprints/capacity-planner/blueprint.md
