# Performance review system database schema

Source: https://personalsoftwarefactory.com/schemas/performance-reviews
Updated: 2026-12-05

> Eleven tables. Reviews carry the design: one row per employee per cycle, with the manager fixed at launch, separate self and manager statuses, the overall rating copied in only when the manager submits, and a calibrated rating that needs a reason. Answers are one row per question per section, and template questions are a child table whose question with id overall is the overall rating.

- 11 tables, 1 index
- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1) on 2026-12-05
- 32 seed rows from the blueprint
- The blueprint's test build passed 17 of 17 acceptance checks

Files: [performance-reviews.sql](https://personalsoftwarefactory.com/schemas/performance-reviews.sql) · [performance-reviews-seed.sql](https://personalsoftwarefactory.com/schemas/performance-reviews-seed.sql) · [the Performance Reviews blueprint](https://personalsoftwarefactory.com/blueprints/performance-reviews)

## 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.
- template_questions.template_id references templates.id: each template_questions row points to exactly one templates row, and one templates row can have many template_questions rows pointing to it.
- cycles.template_id references templates.id: each cycles row points to exactly one templates row, and one templates row can have many cycles rows pointing to it.
- reviews.cycle_id references cycles.id: each reviews row points to exactly one cycles row, and one cycles row can have many reviews rows pointing to it.
- reviews.employee_id references people.id: each reviews row points to exactly one people row, and one people row can have many reviews rows pointing to it.
- reviews.manager_id references people.id: each reviews row points to exactly one people row, and one people row can have many reviews rows pointing to it.
- answers.review_id references reviews.id: each answers row points to exactly one reviews row, and one reviews row can have many answers rows pointing to it.
- answers.author_id references people.id: each answers row points to exactly one people row, and one people row can have many answers rows pointing to it.
- peer_requests.review_id references reviews.id: each peer_requests row points to exactly one reviews row, and one reviews row can have many peer_requests rows pointing to it.
- peer_requests.peer_id references people.id: each peer_requests row points to exactly one people row, and one people row can have many peer_requests rows pointing to it.
- peer_requests.decided_by references people.id: each peer_requests row points to at most one people row, and one people row can have many peer_requests 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.
- reminders_sent.cycle_id references cycles.id: each reminders_sent row points to exactly one cycles row, and one cycles row can have many reminders_sent rows pointing to it.
- reminders_sent.person_id references people.id: each reminders_sent row points to exactly one people row, and one people row can have many reminders_sent rows pointing to it.

## Tables

Also described as: employee appraisal database design, performance management database tables, 360 feedback data model.

### settings

One company setting per row, such as the company name and time zone. Implements: Setting.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `key` | TEXT | no |  | Primary key |  |
| `value` | TEXT | no |  |  |  |

### people

Someone in the company, with their manager, team, start date and pronouns. Implements: Person.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  |  |
| `email` | TEXT | no |  | Unique | stored lowercase Check: `email = LOWER(email)` |
| `title` | TEXT | yes |  |  |  |
| `team` | TEXT | yes |  |  | calibration groups ratings by the current team |
| `role` | TEXT | no | `'member'` |  | Check: `role IN ('admin', 'member')` |
| `manager_id` | TEXT | yes |  | References people.id |  |
| `start_date` | DATE | no |  |  | compared with the cycle start_date_cutoff at launch (R1) |
| `active` | BOOLEAN | no | `TRUE` |  |  |
| `pronouns` | TEXT | no |  |  | for messages such as: Leo has not submitted his self review yet Check: `pronouns IN ('he', 'she', 'they')` |

- Table check: `manager_id IS NULL OR manager_id <> id`

### templates

A named review form. Implements: Template.

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

### template_questions

One question of a template, with its kind, audience and whether it is required. Implements: child table of Template.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `template_id` | TEXT | no |  | Primary key (part); References templates.id |  |
| `id` | TEXT | no |  | Primary key (part) | stable within the template; answers refer to it |
| `position` | INTEGER | no |  |  | order in the list |
| `text` | TEXT | no |  |  | {name} is replaced with the employee first name |
| `kind` | TEXT | no |  |  | Check: `kind IN ('text', 'rating')` |
| `audience` | TEXT | no |  |  | Check: `audience IN ('self', 'manager', 'both', 'peer')` |
| `required` | BOOLEAN | no |  |  |  |

- Table check: `id <> 'overall' OR (kind = 'rating' AND audience = 'manager' AND required = TRUE)`
- App rule (section 5): every template has the question with id overall (rating, manager, required).

### cycles

A review cycle with its cutoff, due dates, release date and peer-sharing setting. Implements: Cycle.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  |  |
| `template_id` | TEXT | no |  | References templates.id |  |
| `status` | TEXT | no | `'draft'` |  | Check: `status IN ('draft', 'active', 'closed')` |
| `start_date_cutoff` | DATE | yes |  |  | people who started on or before it get a review |
| `self_due` | DATE | yes |  |  |  |
| `peer_due` | DATE | yes |  |  |  |
| `manager_due` | DATE | yes |  |  |  |
| `release_on` | DATE | yes |  |  |  |
| `share_peer_feedback` | BOOLEAN | no |  |  |  |
| `peer_min_for_sharing` | INTEGER | no | `2` |  |  |
| `launched_at` | TIMESTAMP | yes |  |  |  |
| `closed_at` | TIMESTAMP | yes |  |  |  |

- Table check: `status = 'draft' OR (start_date_cutoff IS NOT NULL AND self_due IS NOT NULL AND peer_due IS NOT NULL AND manager_due IS NOT NULL AND release_on IS NOT NULL AND launched_at IS NOT NULL)`
- Table check: `self_due < peer_due AND peer_due <= manager_due AND manager_due < release_on`
- Table check: `status <> 'closed' OR closed_at IS NOT NULL`
- Unique index `cycles_one_active` on (status) where `status = 'active'`
- App rule (section 7): only a draft cycle can be edited; launch is refused when nobody is eligible or an eligible person has an inactive manager.

### reviews

One employee in one cycle, with self and manager status, ratings, release and acknowledgement. Implements: Review.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `cycle_id` | TEXT | no |  | References cycles.id |  |
| `employee_id` | TEXT | no |  | References people.id |  |
| `manager_id` | TEXT | no |  | References people.id | fixed at launch; an admin can reassign it (section 13) |
| `self_status` | TEXT | no | `'not_started'` |  | Check: `self_status IN ('not_started', 'draft', 'submitted')` |
| `manager_status` | TEXT | no | `'not_started'` |  | Check: `manager_status IN ('not_started', 'draft', 'submitted')` |
| `self_submitted_at` | TIMESTAMP | yes |  |  |  |
| `manager_submitted_at` | TIMESTAMP | yes |  |  |  |
| `overall_rating` | INTEGER | yes |  |  | copied from the overall answer when the manager submits Check: `overall_rating BETWEEN 1 AND 5` |
| `calibrated_rating` | INTEGER | yes |  |  | the final rating when set Check: `calibrated_rating BETWEEN 1 AND 5` |
| `calibration_reason` | TEXT | yes |  |  | never shown to the employee (R6) Check: `LENGTH(calibration_reason) BETWEEN 10 AND 500` |
| `released_at` | TIMESTAMP | yes |  |  |  |
| `acknowledged_at` | TIMESTAMP | yes |  |  |  |
| `acknowledgement_comment` | TEXT | yes |  |  | an empty comment is stored as NULL Check: `LENGTH(acknowledgement_comment) BETWEEN 1 AND 1000` |

- Unique together: `cycle_id`, `employee_id`
- Table check: `employee_id <> manager_id`
- Table check: `self_status <> 'submitted' OR self_submitted_at IS NOT NULL`
- Table check: `(manager_status = 'submitted' AND manager_submitted_at IS NOT NULL AND overall_rating IS NOT NULL) OR (manager_status <> 'submitted' AND overall_rating IS NULL)`
- Table check: `(calibrated_rating IS NULL AND calibration_reason IS NULL) OR (calibrated_rating IS NOT NULL AND calibration_reason IS NOT NULL AND manager_status = 'submitted')`
- Table check: `released_at IS NULL OR manager_status = 'submitted'`
- Table check: `acknowledged_at IS NULL OR released_at IS NOT NULL`
- Table check: `acknowledgement_comment IS NULL OR acknowledged_at IS NOT NULL`
- App rule (R2): who sees which part follows the table in section 6, on every request.
- App rule (R4): the manager review can be submitted only after the self review is submitted or self_due has passed.
- App rule (R8): nothing changes after acknowledgement.

### answers

One answer, text or rating, to one question in one section of a review. Implements: Answer.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `review_id` | TEXT | no |  | References reviews.id |  |
| `author_id` | TEXT | no |  | References people.id |  |
| `section` | TEXT | no |  |  | Check: `section IN ('self', 'manager', 'peer')` |
| `question_id` | TEXT | no |  |  | a template_questions id in the cycle template |
| `text` | TEXT | yes |  |  | the maximum applies to drafts too Check: `LENGTH(text) <= 4000` |
| `rating` | INTEGER | yes |  |  | Check: `rating BETWEEN 1 AND 5` |
| `updated_at` | TIMESTAMP | no |  |  |  |

- Unique together: `review_id`, `author_id`, `section`, `question_id`
- Table check: `text IS NULL OR rating IS NULL`
- App rule (R3): on submit, required text answers are 20 to 4,000 characters after trimming and ratings 1 to 5.

### peer_requests

A peer proposed for a review, with the manager decision and the peer response. Implements: PeerRequest.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `review_id` | TEXT | no |  | References reviews.id |  |
| `peer_id` | TEXT | no |  | References people.id |  |
| `status` | TEXT | no | `'proposed'` |  | Check: `status IN ('proposed', 'approved', 'declined', 'submitted', 'peer_declined', 'cancelled')` |
| `decided_by` | TEXT | yes |  | References people.id | the manager fixed on the review |
| `reason` | TEXT | yes |  |  | Check: `LENGTH(reason) BETWEEN 1 AND 500` |
| `submitted_at` | TIMESTAMP | yes |  |  |  |

- Unique together: `review_id`, `peer_id`
- Table check: `status NOT IN ('declined', 'peer_declined', 'cancelled') OR reason IS NOT NULL`
- Table check: `status NOT IN ('approved', 'declined', 'submitted', 'peer_declined') OR decided_by IS NOT NULL`
- Table check: `(status = 'submitted' AND submitted_at IS NOT NULL) OR (status <> 'submitted' AND submitted_at IS NULL)`
- App rule (section 7): 1 to 3 peers per review in total, never the employee or their manager; a decision cannot be changed.

### 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 |

- App rule (R10): events are never edited or deleted, except by the development-only reset to seed data.

### 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 trigger from section 10; 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 |  |  |  |

### reminders_sent

A reminder already sent, so each goes out at most once. Implements: ReminderSent.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `cycle_id` | TEXT | no |  | Primary key (part); References cycles.id |  |
| `step` | TEXT | no |  | Primary key (part) | Check: `step IN ('self', 'peer', 'manager')` |
| `due_date` | DATE | no |  | Primary key (part) |  |
| `reminder_day` | TEXT | no |  | Primary key (part) | the spec field when, renamed (reserved word) Check: `reminder_day IN ('three_days', 'due_day')` |
| `person_id` | TEXT | no |  | Primary key (part); References people.id |  |

## The SQL

```sql
-- Performance Reviews database schema
-- Source: https://personalsoftwarefactory.com/blueprints/performance-reviews (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.

-- Company settings, one row per setting (company name, time zone, sign-in domain, development clock offset).
CREATE TABLE settings (
  key TEXT PRIMARY KEY,
  value TEXT NOT NULL
);

-- Someone in the company. manager_id is empty for the top of the company.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT NOT NULL UNIQUE CHECK (email = LOWER(email)), -- stored lowercase
  title TEXT,
  team TEXT, -- calibration groups ratings by the current team
  role TEXT NOT NULL DEFAULT 'member' CHECK (role IN ('admin', 'member')),
  manager_id TEXT REFERENCES people(id),
  start_date DATE NOT NULL, -- compared with the cycle start_date_cutoff at launch (R1)
  active BOOLEAN NOT NULL DEFAULT TRUE,
  pronouns TEXT NOT NULL CHECK (pronouns IN ('he', 'she', 'they')), -- for messages such as: Leo has not submitted his self review yet
  CHECK (manager_id IS NULL OR manager_id <> id)
);

-- A review form. A template used by a launched cycle is read-only; it is duplicated to change it.
CREATE TABLE templates (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL
);

-- One question of a template, in order. Question ids are unique within a template.
-- App rule (section 5): every template has the question with id overall (rating, manager, required).
CREATE TABLE template_questions (
  template_id TEXT NOT NULL REFERENCES templates(id),
  id TEXT NOT NULL, -- stable within the template; answers refer to it
  position INTEGER NOT NULL, -- order in the list
  text TEXT NOT NULL, -- {name} is replaced with the employee first name
  kind TEXT NOT NULL CHECK (kind IN ('text', 'rating')),
  audience TEXT NOT NULL CHECK (audience IN ('self', 'manager', 'both', 'peer')),
  required BOOLEAN NOT NULL,
  PRIMARY KEY (template_id, id),
  CHECK (id <> 'overall' OR (kind = 'rating' AND audience = 'manager' AND required = TRUE))
);

-- A review cycle. Due dates end at 23:59 in the company time zone.
-- App rule (section 7): only a draft cycle can be edited; launch is refused when nobody is eligible or an eligible person has an inactive manager.
CREATE TABLE cycles (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  template_id TEXT NOT NULL REFERENCES templates(id),
  status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'active', 'closed')),
  start_date_cutoff DATE, -- people who started on or before it get a review
  self_due DATE,
  peer_due DATE,
  manager_due DATE,
  release_on DATE,
  share_peer_feedback BOOLEAN NOT NULL,
  peer_min_for_sharing INTEGER NOT NULL DEFAULT 2,
  launched_at TIMESTAMP,
  closed_at TIMESTAMP,
  CHECK (status = 'draft' OR (start_date_cutoff IS NOT NULL AND self_due IS NOT NULL AND peer_due IS NOT NULL AND manager_due IS NOT NULL AND release_on IS NOT NULL AND launched_at IS NOT NULL)),
  CHECK (self_due < peer_due AND peer_due <= manager_due AND manager_due < release_on), -- launch order (section 7)
  CHECK (status <> 'closed' OR closed_at IS NOT NULL)
);
CREATE UNIQUE INDEX cycles_one_active ON cycles (status) WHERE status = 'active'; -- only one cycle can be active

-- One employee in one cycle. The manager is fixed at launch.
-- App rule (R2): who sees which part follows the table in section 6, on every request.
-- App rule (R4): the manager review can be submitted only after the self review is submitted or self_due has passed.
-- App rule (R8): nothing changes after acknowledgement.
CREATE TABLE reviews (
  id TEXT PRIMARY KEY,
  cycle_id TEXT NOT NULL REFERENCES cycles(id),
  employee_id TEXT NOT NULL REFERENCES people(id),
  manager_id TEXT NOT NULL REFERENCES people(id), -- fixed at launch; an admin can reassign it (section 13)
  self_status TEXT NOT NULL DEFAULT 'not_started' CHECK (self_status IN ('not_started', 'draft', 'submitted')),
  manager_status TEXT NOT NULL DEFAULT 'not_started' CHECK (manager_status IN ('not_started', 'draft', 'submitted')),
  self_submitted_at TIMESTAMP,
  manager_submitted_at TIMESTAMP,
  overall_rating INTEGER CHECK (overall_rating BETWEEN 1 AND 5), -- copied from the overall answer when the manager submits
  calibrated_rating INTEGER CHECK (calibrated_rating BETWEEN 1 AND 5), -- the final rating when set
  calibration_reason TEXT CHECK (LENGTH(calibration_reason) BETWEEN 10 AND 500), -- never shown to the employee (R6)
  released_at TIMESTAMP,
  acknowledged_at TIMESTAMP,
  acknowledgement_comment TEXT CHECK (LENGTH(acknowledgement_comment) BETWEEN 1 AND 1000), -- an empty comment is stored as NULL
  UNIQUE (cycle_id, employee_id),
  CHECK (employee_id <> manager_id),
  CHECK (self_status <> 'submitted' OR self_submitted_at IS NOT NULL),
  CHECK ((manager_status = 'submitted' AND manager_submitted_at IS NOT NULL AND overall_rating IS NOT NULL) OR (manager_status <> 'submitted' AND overall_rating IS NULL)),
  CHECK ((calibrated_rating IS NULL AND calibration_reason IS NULL) OR (calibrated_rating IS NOT NULL AND calibration_reason IS NOT NULL AND manager_status = 'submitted')),
  CHECK (released_at IS NULL OR manager_status = 'submitted'), -- release needs a submitted manager section
  CHECK (acknowledged_at IS NULL OR released_at IS NOT NULL),
  CHECK (acknowledgement_comment IS NULL OR acknowledged_at IS NOT NULL)
);

-- One answer to one question in one section of a review, draft or submitted.
-- App rule (R3): on submit, required text answers are 20 to 4,000 characters after trimming and ratings 1 to 5.
CREATE TABLE answers (
  id TEXT PRIMARY KEY,
  review_id TEXT NOT NULL REFERENCES reviews(id),
  author_id TEXT NOT NULL REFERENCES people(id),
  section TEXT NOT NULL CHECK (section IN ('self', 'manager', 'peer')),
  question_id TEXT NOT NULL, -- a template_questions id in the cycle template
  text TEXT CHECK (LENGTH(text) <= 4000), -- the maximum applies to drafts too
  rating INTEGER CHECK (rating BETWEEN 1 AND 5),
  updated_at TIMESTAMP NOT NULL,
  UNIQUE (review_id, author_id, section, question_id),
  CHECK (text IS NULL OR rating IS NULL) -- text or rating
);

-- A peer the employee proposed to give feedback on their review.
-- App rule (section 7): 1 to 3 peers per review in total, never the employee or their manager; a decision cannot be changed.
CREATE TABLE peer_requests (
  id TEXT PRIMARY KEY,
  review_id TEXT NOT NULL REFERENCES reviews(id),
  peer_id TEXT NOT NULL REFERENCES people(id),
  status TEXT NOT NULL DEFAULT 'proposed' CHECK (status IN ('proposed', 'approved', 'declined', 'submitted', 'peer_declined', 'cancelled')),
  decided_by TEXT REFERENCES people(id), -- the manager fixed on the review
  reason TEXT CHECK (LENGTH(reason) BETWEEN 1 AND 500),
  submitted_at TIMESTAMP,
  UNIQUE (review_id, peer_id), -- a declined peer cannot be proposed again
  CHECK (status NOT IN ('declined', 'peer_declined', 'cancelled') OR reason IS NOT NULL),
  CHECK (status NOT IN ('approved', 'declined', 'submitted', 'peer_declined') OR decided_by IS NOT NULL),
  CHECK ((status = 'submitted' AND submitted_at IS NOT NULL) OR (status <> 'submitted' AND submitted_at IS NULL))
);

-- One line of the append-only activity log.
-- App rule (R10): events are never edited or deleted, except by the development-only reset to seed data.
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 by created_at.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  created_at TIMESTAMP NOT NULL,
  kind TEXT NOT NULL, -- the trigger from section 10; 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
);

-- A reminder that has been sent, so each one goes out at most once (R9).
CREATE TABLE reminders_sent (
  cycle_id TEXT NOT NULL REFERENCES cycles(id),
  step TEXT NOT NULL CHECK (step IN ('self', 'peer', 'manager')),
  due_date DATE NOT NULL,
  reminder_day TEXT NOT NULL CHECK (reminder_day IN ('three_days', 'due_day')), -- the spec field when, renamed (reserved word)
  person_id TEXT NOT NULL REFERENCES people(id),
  PRIMARY KEY (cycle_id, step, due_date, reminder_day, person_id)
);
```

## Seed data

Loads 2 settings (company name, time zone), 9 people, the Half-year review template with its 8 questions, the active H2 2026 cycle, its 7 reviews and 4 peer requests. Dates without a time use 12:00 UTC (the self review submissions on Oct 13 and 14); the launch at Mon Oct 12, 09:00 company time is 14:00 UTC. Placeholder: start_date is 2026-01-01 for the 8 people the spec says only started before Sep 30, 2026; no query depends on the exact date. Question ids other than overall are short names given here, because the spec gives none. Left out: the H1 2026 cycle and Ivy Tan's H1 review, because the spec gives no cutoff, peer-sharing flag, launch or close time, submission times, acknowledgement time or comment text, and the peer-sharing flag cannot be filled with a placeholder; all answers (submitted self reviews and Leo Grant's draft), because the spec gives no answer text or rating values; and the 9 outbox emails and their events, because the spec gives no notification kinds, bodies, event types or peer-approval times.

## Load it

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

## Design decisions

### Template questions are a child table, and overall is a fixed id

Section 5 gives a template a list of questions, each with an id, text, kind, audience and required flag. They are a child table keyed by template and question id, because the build test found the overall rating question and Review.overall_rating were never linked; the spec now says every template has the question with id overall (rating, manager, required), which a CHECK enforces on that row. (This point comes from a gap the blueprint's build test found.)

### The overall rating is copied only on manager submit

Section 5 keeps a draft overall rating as an answer that only the manager sees and copies it to reviews.overall_rating when the manager submits. A CHECK ties overall_rating to manager_status = submitted, so reopening the manager review, which clears the rating, cannot leave a stale one behind. A calibrated rating needs a reason of 10 to 500 characters (R6).

### Release and acknowledgement follow the manager section

Section 7 releases only reviews whose manager section is submitted, and acknowledgement happens after release, once, with an optional comment of up to 1,000 characters. CHECKs make released_at need a submitted manager section and acknowledged_at need released_at; an empty comment is stored as NULL, as the spec says.

### One active cycle at a time

Section 7 refuses a launch while another cycle is active. A partial unique index on status WHERE status = 'active' allows any number of draft and closed cycles but only one active one. Launch also needs every date, in order, which table CHECKs enforce once the cycle leaves draft.

### Peer requests keep their reason and decider

Section 5 requires a reason of 1 to 500 characters for declined, peer_declined and cancelled requests, and only the manager on the review decides. CHECKs require the reason and decided_by for those statuses. UNIQUE (review_id, peer_id) also stops a declined peer from being proposed again. The build test found that decline reasons had no length and that the decision rules were missing; both are now in the spec. (This point comes from a gap the blueprint's build test found.)

### The reminder log is the idempotency key

R9 sends each reminder at most once per cycle, step, due date, reminder day and person, so those five columns are the primary key of reminders_sent and a second run of the job fails to insert a duplicate. The spec names the reminder-day field when, a reserved word in both engines, so it is reminder_day here.

### Settings are key and value rows; sessions are left out

Section 5 says Setting holds the company settings and the development clock offset without naming fields, so settings is a key and value table rather than columns made up here. Session is named but has no fields in the spec, so it is not a table here; use your sign-in library session table.

## Example queries

### Cycle dashboard: every review with its step statuses

```sql
SELECT e.name AS employee, e.team, m.name AS manager, r.self_status, r.manager_status FROM reviews r JOIN cycles c ON c.id = r.cycle_id JOIN people e ON e.id = r.employee_id JOIN people m ON m.id = r.manager_id WHERE c.status = 'active' ORDER BY e.name;
```

On the seed data: 7 rows, from Ella Ford (not_started, manager Sofia Ruiz) to Sofia Ruiz (submitted, manager Dan Price).

### Peer proposals waiting for the manager

```sql
SELECT e.name AS employee, p.name AS proposed_peer, m.name AS manager FROM peer_requests pr JOIN reviews r ON r.id = pr.review_id JOIN people e ON e.id = r.employee_id JOIN people p ON p.id = pr.peer_id JOIN people m ON m.id = r.manager_id WHERE pr.status = 'proposed' ORDER BY e.name, p.name;
```

On the seed data: 2 rows, Kai Moore proposing Ella Ford and Ivy Tan, waiting for Sofia Ruiz.

### Peer requests waiting for each peer

```sql
SELECT p.name AS peer, e.name AS feedback_for, c.peer_due FROM peer_requests pr JOIN reviews r ON r.id = pr.review_id JOIN cycles c ON c.id = r.cycle_id JOIN people e ON e.id = r.employee_id JOIN people p ON p.id = pr.peer_id WHERE pr.status = 'approved' ORDER BY p.name;
```

On the seed data: 2 rows, Kai Moore and Leo Grant, both for Ivy Tan, due 2026-10-29.

### Overdue self reviews on Fri Oct 23

```sql
SELECT e.name AS employee, r.self_status, CASE WHEN e.active THEN 'active' ELSE 'inactive' END AS person_status FROM reviews r JOIN cycles c ON c.id = r.cycle_id JOIN people e ON e.id = r.employee_id WHERE c.status = 'active' AND r.self_status <> 'submitted' AND r.released_at IS NULL AND c.self_due < '2026-10-23' ORDER BY e.name;
```

On the seed data: 4 rows, Ella Ford, Hannah Cole, Leo Grant (draft) and Marcus Webb.

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