OKR software database schema

Ten tables. Objectives belong to a cycle at company or team level, and key results store start, target and current values as integer hundredths, with CHECKs that make a lower-is-better target sit below its start and pin milestones to 0 and 100. Check-ins and target changes are append-only logs that keep their key result id without a foreign key, so history survives a deleted key result. Progress is computed, not stored, until a cycle closes and freezes it in basis points.

  • 10 tables, 4 indexes
  • Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1),
  • 30 seed rows from the blueprint
  • The blueprint's test build passed 19 of 19 acceptance checks

Copy the SQLDownload SQLDownload seed data

By Sam Claassen · From the OKR Tracker blueprint · MIT licensed · Markdown version

OKR tracker entity-relationship diagram

settingsidPK+ 8 more columnsteamsidPK+ 2 more columnspeopleidPKteam_id→ teams+ 4 more columnscyclesidPKclosed_by→ people+ 5 more columnsobjectivesidPKcycle_id→ cyclesteam_id→ teamsowner_id→ peoplealigned_to_id→ objectivescarried_from_id→ objectives+ 5 more columnskey_resultsidPKobjective_id→ objectivesowner_id→ peoplecarried_from_id→ key_results+ 11 more columnscheck_insidPKby_id→ people+ 5 more columnstarget_changesidPKby_id→ people+ 6 more columnseventsidPKactor→ people+ 3 more columnsnotificationsidPK+ 8 more columnssettingsidPK+ 8 more columnsteamsidPK+ 2 more columnspeopleidPKteam_id→ teams+ 4 more columnscyclesidPKclosed_by→ people+ 5 more columnsobjectivesidPKcycle_id→ cyclesteam_id→ teamsowner_id→ peoplealigned_to_id→ objectivescarried_from_id→ objectives+ 5 more columnskey_resultsidPKobjective_id→ objectivesowner_id→ peoplecarried_from_id→ key_results+ 11 more columnscheck_insidPKby_id→ people+ 5 more columnstarget_changesidPKby_id→ people+ 6 more columnseventsidPKactor→ people+ 3 more columnsnotificationsidPK+ 8 more columns
Each box is a table with its key columns. A line runs from a table up to a table it references, with the forked end on the side that has many rows; a dashed line is an optional reference.

Relationships

  • people.team_id references teams.id: each people row points to at most one teams row, and one teams row can have many people rows pointing to it.
  • cycles.closed_by references people.id: each cycles row points to at most one people row, and one people row can have many cycles rows pointing to it.
  • objectives.cycle_id references cycles.id: each objectives row points to exactly one cycles row, and one cycles row can have many objectives rows pointing to it.
  • objectives.team_id references teams.id: each objectives row points to at most one teams row, and one teams row can have many objectives rows pointing to it.
  • objectives.owner_id references people.id: each objectives row points to exactly one people row, and one people row can have many objectives rows pointing to it.
  • objectives.aligned_to_id references objectives.id: each objectives row points to at most one another objectives row, and one objectives row can have many objectives rows pointing to it.
  • objectives.carried_from_id references objectives.id: each objectives row points to at most one another objectives row, and one objectives row can have many objectives rows pointing to it.
  • key_results.objective_id references objectives.id: each key_results row points to exactly one objectives row, and one objectives row can have many key_results rows pointing to it. On delete: cascade.
  • key_results.owner_id references people.id: each key_results row points to exactly one people row, and one people row can have many key_results rows pointing to it.
  • key_results.carried_from_id references key_results.id: each key_results row points to at most one another key_results row, and one key_results row can have many key_results rows pointing to it.
  • check_ins.by_id references people.id: each check_ins row points to exactly one people row, and one people row can have many check_ins rows pointing to it.
  • target_changes.by_id references people.id: each target_changes row points to exactly one people row, and one people row can have many target_changes 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.

OKR tracker tables

The schema has 10 tables. Every column below is read from the SQL file itself. Also described as: objectives and key results database design, OKR tracking database tables, goal tracking schema.

TableImplementsWhat a row is
settingsSettingsThe single row of company settings: domain, currency, time zone and reminder and summary schedule.
teamsTeamA team with an optional lead.
peoplePersonSomeone who can sign in, an admin or a member, with an optional team.
cyclesCycleA goal-setting period, usually a quarter, in planning, active or closed.
objectivesObjectiveA company or team objective in a cycle, with its owner, alignment and final score.
key_resultsKeyResultA measurable result of an objective, with start, target and current values in hundredths.
check_insCheckInOne append-only check-in: a new value, a confidence and a comment.
target_changesTargetChangeOne append-only change to a key result's start or target in an active cycle, with its reason.
eventsEventAn append-only audit entry for a change.
notificationsNotificationAn email in the outbox, written before it is sent, with its status.

settings

Company settings. Exactly one row.

ColumnTypeNullDefaultKeyNotes
idINTEGERnoPrimary keykeeps this table to one rowCheck: id = 1
company_nameTEXTno
email_domainTEXTnosign-in is limited to this domain
currencyTEXTno'USD'used by every currency key result
time_zoneTEXTno'America/New_York'IANA name; days and job times are reckoned here
reminder_dayTEXTno'Monday'Check: reminder_day IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')
reminder_timeTEXTno'09:00'"HH:MM" company time
summary_dayTEXTno'Friday'Check: summary_day IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')
summary_timeTEXTno'16:00'"HH:MM" company time

teams

A team. At most one lead, who need not be a member; a team may have no lead.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnoCheck: length(name) <= 100
lead_idTEXTyesa person id; no foreign key because people.team_id points back here (create order)
  • Unique index teams_name_unique on (lower(name)). Team names are unique ignoring case.
  • App rule (section 4): deleted only when it has no people and no objectives.

people

A person who can sign in. Team leads are found through teams.lead_id.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnoCheck: length(name) <= 100
emailTEXTnoUniquetrimmed and lowercase
roleTEXTnoCheck: role IN ('admin', 'member')
team_idTEXTyesReferences teams.idoptional
activeBOOLEANnoTRUE
  • Table check: email = lower(email)
  • App rule (section 4): an admin cannot deactivate themselves; the last active admin cannot be demoted or deactivated.

cycles

A goal-setting period, usually a calendar quarter. Cannot be edited or deleted in v1; closed cycles are read-only.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnosuch as "Q4 2026"Check: length(name) BETWEEN 1 AND 50
starts_onDATEno
ends_onDATEno
statusTEXTno'planning'Check: status IN ('planning', 'active', 'closed')
closed_atTIMESTAMPyes
closed_byTEXTyesReferences people.id
  • Table check: ends_on > starts_on
  • Table check: status <> 'closed' OR (closed_at IS NOT NULL AND closed_by IS NOT NULL)
  • Table check: status <> 'planning' OR (closed_at IS NULL AND closed_by IS NULL)
  • Unique index cycles_name_unique on (lower(name)). Cycle names are unique ignoring case.
  • Unique index cycles_one_active on (status) where status = 'active'. Only one active cycle at a time.
  • App rule (section 7): cycle dates must not overlap another cycle (touching dates are fine).

objectives

An objective in a cycle, for the company or for one team.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
cycle_idTEXTnoReferences cycles.id
levelTEXTnocannot change after creationCheck: level IN ('company', 'team')
team_idTEXTyesReferences teams.idteam level only; cannot change after creation
titleTEXTnoCheck: length(title) <= 200
descriptionTEXTyesCheck: length(description) <= 2000
owner_idTEXTnoReferences people.id
aligned_to_idTEXTyesReferences objectives.idoptional; no cascade, so a company objective with aligned team objectives cannot be deleted (R6)
positionINTEGERnoorder within its company or team list
final_score_bpINTEGERyesset at close, basis points: 6875 shows as 0.7Check: final_score_bp BETWEEN 0 AND 10000
carried_from_idTEXTyesReferences objectives.idthe objective this one was copied from at a close (R7)
  • Table check: (level = 'company' AND team_id IS NULL) OR (level = 'team' AND team_id IS NOT NULL)
  • Table check: aligned_to_id IS NULL OR level = 'team'
  • App rule (R1): 1 to 5 key results; at most 5 objectives per team, and 5 for the company, per cycle.
  • App rule (R6): aligned_to_id is a company objective in the same cycle.

key_results

A measurable key result of an objective. Progress is computed, not stored (section 6), except final_progress_bp at close.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
objective_idTEXTnoReferences objectives.id, on delete cascade
titleTEXTnofree text; does not change when a target changesCheck: length(title) <= 200
owner_idTEXTnoReferences people.id
metricTEXTnoCheck: metric IN ('number', 'percent', 'currency', 'milestone')
unitTEXTyessuch as "hours"; optional for numbers, empty for percent, currency and milestonesCheck: length(unit) <= 30
directionTEXTnoCheck: direction IN ('increase', 'decrease')
start_x100INTEGERnohundredths; milestones store 0
target_x100INTEGERnohundredths; milestones store 100
current_x100INTEGERnohundredths; milestones store 0 or 100; a new key result starts at start_x100
confidenceTEXTyesfrom the latest check-in; NULL until the firstCheck: confidence IN ('on_track', 'at_risk', 'off_track')
last_check_in_atTIMESTAMPyes
final_progress_bpINTEGERyesset at close, basis pointsCheck: final_progress_bp BETWEEN 0 AND 10000
positionINTEGERnoorder within its objective
carried_from_idTEXTyesReferences key_results.idthe key result it was carried forward from (R7)
  • Table check: unit IS NULL OR metric = 'number'
  • Table check: metric <> 'milestone' OR (direction = 'increase' AND start_x100 = 0 AND target_x100 = 100 AND current_x100 IN (0, 100))
  • Table check: metric <> 'percent' OR (start_x100 BETWEEN 0 AND 10000 AND target_x100 BETWEEN 0 AND 10000 AND current_x100 BETWEEN 0 AND 10000)
  • Table check: (direction = 'increase' AND target_x100 > start_x100) OR (direction = 'decrease' AND target_x100 < start_x100)
  • Table check: (confidence IS NULL) = (last_check_in_at IS NULL)
  • App rule (R2): the owner is active. App rule (section 13): the metric cannot change once check-ins exist.

check_ins

One check-in on a key result. Append-only (R4): sets the key result's current value, confidence and last_check_in_at.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
key_result_idTEXTnono foreign key: check-ins stay when their key result is deleted (R1)
atTIMESTAMPno
by_idTEXTnoReferences people.id
value_x100INTEGERnohundredths; percent check-ins are 0 to 10000 (app rule, depends on the key result's metric)
confidenceTEXTnoCheck: confidence IN ('on_track', 'at_risk', 'off_track')
commentTEXTnotrimmed before it is storedCheck: length(comment) BETWEEN 3 AND 1000
  • Index check_ins_key_result on (key_result_id, at)
  • App rule (section 7): refused unless the cycle is active.

target_changes

A change to a key result's start or target once its cycle is active (R5). Append-only.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
key_result_idTEXTnono foreign key: target changes stay when their key result is deleted (R1)
atTIMESTAMPno
by_idTEXTnoReferences people.id
fieldTEXTnoCheck: field IN ('start', 'target')
old_x100INTEGERno
new_x100INTEGERno
reasonTEXTnoCheck: length(trim(reason)) BETWEEN 5 AND 300

events

Audit log entry. Append-only (R10). A cycle reopen stores its reason here.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
atTIMESTAMPno
actorTEXTyesReferences people.idNULL when the hourly job acted
typeTEXTno
dataTEXTyesdetails as JSON text

notifications

An email in the outbox. Written here first, then sent. Failed emails stay failed in v1.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
created_atTIMESTAMPno
kindTEXTnowhich email it is: one of the triggers in section 10
to_emailTEXTno
subjectTEXTno
bodyTEXTno
statusTEXTno'queued'logged when no provider is configuredCheck: status IN ('queued', 'sent', 'failed', 'logged')
sent_atTIMESTAMPyes
errorTEXTyes

The SQL

The whole schema in one file. It runs top to bottom, unmodified, on SQLite and PostgreSQL. Download okr-tracker.sql or copy it from here.

okr-tracker.sql
-- OKR Tracker database schema
-- Source: https://personalsoftwarefactory.com/blueprints/okr-tracker (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.
-- Key result values are integer hundredths (8.5% is 850, $40,000 is 4000000). INTEGER is 4 bytes in PostgreSQL,
-- so a value must stay within about +/- 21.4 million units (2147483647 hundredths).

-- Company settings. Exactly one row.
CREATE TABLE settings (
  id INTEGER PRIMARY KEY CHECK (id = 1), -- keeps this table to one row
  company_name TEXT NOT NULL,
  email_domain TEXT NOT NULL, -- sign-in is limited to this domain
  currency TEXT NOT NULL DEFAULT 'USD', -- used by every currency key result
  time_zone TEXT NOT NULL DEFAULT 'America/New_York', -- IANA name; days and job times are reckoned here
  reminder_day TEXT NOT NULL DEFAULT 'Monday' CHECK (reminder_day IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')),
  reminder_time TEXT NOT NULL DEFAULT '09:00', -- "HH:MM" company time
  summary_day TEXT NOT NULL DEFAULT 'Friday' CHECK (summary_day IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')),
  summary_time TEXT NOT NULL DEFAULT '16:00' -- "HH:MM" company time
);

-- A team. At most one lead, who need not be a member; a team may have no lead.
-- App rule (section 4): deleted only when it has no people and no objectives.
CREATE TABLE teams (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (length(name) <= 100),
  lead_id TEXT -- a person id; no foreign key because people.team_id points back here (create order)
);

-- Team names are unique ignoring case.
CREATE UNIQUE INDEX teams_name_unique ON teams (lower(name));

-- A person who can sign in. Team leads are found through teams.lead_id.
-- App rule (section 4): an admin cannot deactivate themselves; the last active admin cannot be demoted or deactivated.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (length(name) <= 100),
  email TEXT NOT NULL UNIQUE, -- trimmed and lowercase
  role TEXT NOT NULL CHECK (role IN ('admin', 'member')),
  team_id TEXT REFERENCES teams(id), -- optional
  active BOOLEAN NOT NULL DEFAULT TRUE,
  CHECK (email = lower(email))
);

-- A goal-setting period, usually a calendar quarter. Cannot be edited or deleted in v1; closed cycles are read-only.
-- App rule (section 7): cycle dates must not overlap another cycle (touching dates are fine).
CREATE TABLE cycles (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 50), -- such as "Q4 2026"
  starts_on DATE NOT NULL,
  ends_on DATE NOT NULL,
  status TEXT NOT NULL DEFAULT 'planning' CHECK (status IN ('planning', 'active', 'closed')),
  closed_at TIMESTAMP,
  closed_by TEXT REFERENCES people(id),
  CHECK (ends_on > starts_on),
  CHECK (status <> 'closed' OR (closed_at IS NOT NULL AND closed_by IS NOT NULL)),
  CHECK (status <> 'planning' OR (closed_at IS NULL AND closed_by IS NULL))
);

-- Cycle names are unique ignoring case.
CREATE UNIQUE INDEX cycles_name_unique ON cycles (lower(name));
-- Only one active cycle at a time.
CREATE UNIQUE INDEX cycles_one_active ON cycles (status) WHERE status = 'active';

-- An objective in a cycle, for the company or for one team.
-- App rule (R1): 1 to 5 key results; at most 5 objectives per team, and 5 for the company, per cycle.
-- App rule (R6): aligned_to_id is a company objective in the same cycle.
CREATE TABLE objectives (
  id TEXT PRIMARY KEY,
  cycle_id TEXT NOT NULL REFERENCES cycles(id),
  level TEXT NOT NULL CHECK (level IN ('company', 'team')), -- cannot change after creation
  team_id TEXT REFERENCES teams(id), -- team level only; cannot change after creation
  title TEXT NOT NULL CHECK (length(title) <= 200),
  description TEXT CHECK (length(description) <= 2000),
  owner_id TEXT NOT NULL REFERENCES people(id),
  aligned_to_id TEXT REFERENCES objectives(id), -- optional; no cascade, so a company objective with aligned team objectives cannot be deleted (R6)
  position INTEGER NOT NULL, -- order within its company or team list
  final_score_bp INTEGER CHECK (final_score_bp BETWEEN 0 AND 10000), -- set at close, basis points: 6875 shows as 0.7
  carried_from_id TEXT REFERENCES objectives(id), -- the objective this one was copied from at a close (R7)
  CHECK ((level = 'company' AND team_id IS NULL) OR (level = 'team' AND team_id IS NOT NULL)),
  CHECK (aligned_to_id IS NULL OR level = 'team')
);

-- A measurable key result of an objective. Progress is computed, not stored (section 6), except final_progress_bp at close.
-- App rule (R2): the owner is active. App rule (section 13): the metric cannot change once check-ins exist.
CREATE TABLE key_results (
  id TEXT PRIMARY KEY,
  objective_id TEXT NOT NULL REFERENCES objectives(id) ON DELETE CASCADE,
  title TEXT NOT NULL CHECK (length(title) <= 200), -- free text; does not change when a target changes
  owner_id TEXT NOT NULL REFERENCES people(id),
  metric TEXT NOT NULL CHECK (metric IN ('number', 'percent', 'currency', 'milestone')),
  unit TEXT CHECK (length(unit) <= 30), -- such as "hours"; optional for numbers, empty for percent, currency and milestones
  direction TEXT NOT NULL CHECK (direction IN ('increase', 'decrease')),
  start_x100 INTEGER NOT NULL, -- hundredths; milestones store 0
  target_x100 INTEGER NOT NULL, -- hundredths; milestones store 100
  current_x100 INTEGER NOT NULL, -- hundredths; milestones store 0 or 100; a new key result starts at start_x100
  confidence TEXT CHECK (confidence IN ('on_track', 'at_risk', 'off_track')), -- from the latest check-in; NULL until the first
  last_check_in_at TIMESTAMP,
  final_progress_bp INTEGER CHECK (final_progress_bp BETWEEN 0 AND 10000), -- set at close, basis points
  position INTEGER NOT NULL, -- order within its objective
  carried_from_id TEXT REFERENCES key_results(id), -- the key result it was carried forward from (R7)
  CHECK (unit IS NULL OR metric = 'number'),
  CHECK (metric <> 'milestone' OR (direction = 'increase' AND start_x100 = 0 AND target_x100 = 100 AND current_x100 IN (0, 100))),
  CHECK (metric <> 'percent' OR (start_x100 BETWEEN 0 AND 10000 AND target_x100 BETWEEN 0 AND 10000 AND current_x100 BETWEEN 0 AND 10000)),
  -- R2 and section 13: the target differs from the start, in the key result's direction
  CHECK ((direction = 'increase' AND target_x100 > start_x100) OR (direction = 'decrease' AND target_x100 < start_x100)),
  CHECK ((confidence IS NULL) = (last_check_in_at IS NULL))
);

-- One check-in on a key result. Append-only (R4): sets the key result's current value, confidence and last_check_in_at.
-- App rule (section 7): refused unless the cycle is active.
CREATE TABLE check_ins (
  id TEXT PRIMARY KEY,
  key_result_id TEXT NOT NULL, -- no foreign key: check-ins stay when their key result is deleted (R1)
  at TIMESTAMP NOT NULL,
  by_id TEXT NOT NULL REFERENCES people(id),
  value_x100 INTEGER NOT NULL, -- hundredths; percent check-ins are 0 to 10000 (app rule, depends on the key result's metric)
  confidence TEXT NOT NULL CHECK (confidence IN ('on_track', 'at_risk', 'off_track')),
  comment TEXT NOT NULL CHECK (length(comment) BETWEEN 3 AND 1000) -- trimmed before it is stored
);

CREATE INDEX check_ins_key_result ON check_ins (key_result_id, at);

-- A change to a key result's start or target once its cycle is active (R5). Append-only.
CREATE TABLE target_changes (
  id TEXT PRIMARY KEY,
  key_result_id TEXT NOT NULL, -- no foreign key: target changes stay when their key result is deleted (R1)
  at TIMESTAMP NOT NULL,
  by_id TEXT NOT NULL REFERENCES people(id),
  field TEXT NOT NULL CHECK (field IN ('start', 'target')),
  old_x100 INTEGER NOT NULL,
  new_x100 INTEGER NOT NULL,
  reason TEXT NOT NULL CHECK (length(trim(reason)) BETWEEN 5 AND 300)
);

-- Audit log entry. Append-only (R10). A cycle reopen stores its reason here.
CREATE TABLE events (
  id TEXT PRIMARY KEY,
  at TIMESTAMP NOT NULL,
  actor TEXT REFERENCES people(id), -- NULL when the hourly job acted
  type TEXT NOT NULL,
  data TEXT -- details as JSON text
);

-- An email in the outbox. Written here first, then sent. Failed emails stay failed in v1.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  created_at TIMESTAMP NOT NULL,
  kind TEXT NOT NULL, -- which email it is: one of the triggers in section 10
  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')), -- logged when no provider is configured
  sent_at TIMESTAMP,
  error TEXT
);

Seed data

Loads Fernway from section 14: the settings row, 3 teams, 6 people, the closed Q3 2026 and active Q4 2026 cycles, 6 objectives and 12 key results with their current values, confidence and Q3 final scores. Left out: the Q4 check-in history, because the spec says each key result has "two or three" check-ins with values stepping toward the current one and a one-line comment, without giving the count, values or comments; Q3's check-ins, which the spec does not describe (so Q3 key results have no confidence); and target changes, events and emails, which start empty. last_check_in_at is loaded from the spec's ages at 10:00 New York time: 9 days ago for the partner program page, 8 for help articles, and 2 days for the rest, which the spec gives as "1 or 2 days ago". Objectives have no description in the spec.

Download okr-tracker-seed.sql (30 rows). It loads with foreign keys enforced on both engines.

Load it

SQLite, into a new file:

sqlite3
curl -s https://personalsoftwarefactory.com/schemas/okr-tracker.sql https://personalsoftwarefactory.com/schemas/okr-tracker-seed.sql | sqlite3 okr_tracker.db

PostgreSQL, into a new database:

psql
createdb okr_tracker && curl -s https://personalsoftwarefactory.com/schemas/okr-tracker.sql https://personalsoftwarefactory.com/schemas/okr-tracker-seed.sql | psql -v ON_ERROR_STOP=1 okr_tracker

SQLite only enforces foreign keys when the connection asks for it: run PRAGMA foreign_keys = ON; when your app opens the database.

Design decisions

Values are integer hundredths; milestones store 0 and 100

From the build test · field report

Section 3 stores key result values as integer hundredths and never as floats, so 8.5% is 850 and $40,000 is 4000000. The build test found that "milestones: 0 and 100" sat among fields stored in hundredths, so 100 could mean 1; the spec now says milestones store 0 and 100 literally, and a CHECK pins a milestone to start 0, target 100, current 0 or 100 and direction increase. INTEGER is 4 bytes in PostgreSQL, so values must stay within about 21.4 million units.

The target must lie in the key result's direction

R2 needs a target different from the start, and section 13 refuses a lower-is-better key result whose target is above its start (and the reverse). One CHECK covers both: an increase needs target above start and a decrease needs target below start. With that, the single progress formula in section 6, (current - start) / (target - start), works for both directions.

Check-ins and target changes outlive their key result

From the build test · field report

R1 lets objectives and key results be deleted while their check-ins, target changes and events stay. The build test found the spec had not said whether they could be deleted or what happened to their check-ins. A foreign key would block the delete or remove the history, so check_ins.key_result_id and target_changes.key_result_id are plain columns with an index.

Final scores are stored in basis points at close

From the build test · field report

Progress is computed every time (section 6), but R7 freezes it when a cycle closes: final_progress_bp on each key result and final_score_bp on each objective. The build test found final_score had no stored unit; the spec now stores basis points (6875 shows as 0.7), and CHECKs keep both between 0 and 10000.

Alignment is a self-reference that blocks deletes

A team objective may align to one company objective in the same cycle, and deleting a company objective that has aligned team objectives is refused (R6). aligned_to_id references objectives with no ON DELETE action, so the database refuses that delete by itself, and a CHECK allows alignment only on team objectives. "Same cycle" spans two rows and stays an app rule.

One active cycle, unique names

Section 7 allows only one active cycle at a time and makes cycle names unique ignoring case, up to 50 characters. A partial unique index on cycles (status) WHERE status = 'active' and a unique index on lower(name) enforce both. Non-overlapping dates compare rows and stay in the app.

A team's lead has no foreign key

people.team_id points to teams and teams.lead_id points to people, a true cycle. PostgreSQL cannot create a reference to a table that does not exist yet, so lead_id keeps the column without a foreign key, and the app checks it is an existing person. A lead need not be a member of the team (section 4).

Example queries

The queries behind the tool's main screens. Each returned the same rows on both engines against the seed data.

Key result progress, as whole percentages

SQL
SELECT o.title AS objective, k.title AS key_result, CASE WHEN (k.current_x100 - k.start_x100) * 1.0 / (k.target_x100 - k.start_x100) <= 0 THEN 0 WHEN (k.current_x100 - k.start_x100) * 1.0 / (k.target_x100 - k.start_x100) >= 1 THEN 100 ELSE ROUND(100.0 * (k.current_x100 - k.start_x100) / (k.target_x100 - k.start_x100)) END AS progress_pct FROM key_results k JOIN objectives o ON o.id = k.objective_id LEFT JOIN teams tm ON tm.id = o.team_id WHERE o.cycle_id = 'q4-2026' ORDER BY o.level, COALESCE(tm.name, ''), o.position, k.position;

On the seed data: 10 rows in OKRs-page order (company, then teams A to Z), from Increase trial-to-paid conversion at 25 to Publish 20 help articles at 100; median first response is 38 (37.5 rounded half up).

Objective progress (plain average of exact key result progress)

SQL
SELECT o.title, ROUND(100.0 * AVG(CASE WHEN (k.current_x100 - k.start_x100) * 1.0 / (k.target_x100 - k.start_x100) <= 0 THEN 0 WHEN (k.current_x100 - k.start_x100) * 1.0 / (k.target_x100 - k.start_x100) >= 1 THEN 1 ELSE (k.current_x100 - k.start_x100) * 1.0 / (k.target_x100 - k.start_x100) END)) AS progress_pct FROM objectives o JOIN key_results k ON k.objective_id = o.id LEFT JOIN teams tm ON tm.id = o.team_id WHERE o.cycle_id = 'q4-2026' GROUP BY o.id, o.title, o.level, tm.name, o.position ORDER BY o.level, COALESCE(tm.name, ''), o.position;

On the seed data: 5 rows, matching section 14 (Grow revenue from self-serve customers 14, Keep customers longer 35, then the teams A to Z: Make the trial easier to start 70, Build a partner channel 15, Answer customers faster 69).

Monday reminder: not checked in for 7 days or more (R8)

SQL
SELECT p.name AS owner, p.email, k.title FROM key_results k JOIN objectives o ON o.id = k.objective_id JOIN cycles c ON c.id = o.cycle_id JOIN people p ON p.id = k.owner_id WHERE c.status = 'active' AND (k.last_check_in_at IS NULL OR k.last_check_in_at < '2026-10-13 04:00:00') ORDER BY p.name, k.title;

On the seed data, for Monday Oct 19 (latest check-in dated Oct 12 or earlier in New York, so before 2026-10-13 04:00 UTC): 2 rows (Ben Ortiz, Launch the partner program page; Sam Lee, Publish 20 help articles).

Alignment view

SQL
SELECT c.title AS company_objective, t.title AS team_objective, tm.name AS team FROM objectives c LEFT JOIN objectives t ON t.aligned_to_id = c.id LEFT JOIN teams tm ON tm.id = t.team_id WHERE c.level = 'company' AND c.cycle_id = 'q4-2026' ORDER BY c.position, tm.name;

On the seed data: 3 rows (Grow revenue from self-serve customers with Make the trial easier to start (Product) and Build a partner channel (Sales); Keep customers longer with Answer customers faster (Support)).

Final scores of closed cycles

SQL
SELECT cy.name AS cycle, o.title AS objective, o.final_score_bp, k.title AS key_result, k.final_progress_bp FROM cycles cy JOIN objectives o ON o.cycle_id = cy.id JOIN key_results k ON k.objective_id = o.id WHERE cy.status = 'closed' ORDER BY cy.starts_on, o.position, k.position;

On the seed data: 2 rows for Q3 2026, Launch self-serve checkout at 8000 basis points (0.8): Ship checkout to all plans 10000, Reach 200 self-serve signups a month 6000.

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 comes from

Tables are the easy half. This schema is section 5 of the OKR Tracker blueprint, a free spec that also has the business rules, the screens, 4 phased build prompts and 19 acceptance checks for building the whole tool with an AI app builder. We built it from those prompts and the result passed 19 of 19 acceptance checks in a browser.

Follow new blueprints

Every new blueprint and build test appears in the feed and in the public GitHub repository. No account, no email list.