Applicant tracking system database schema
Thirteen tables. Applications carry the design: one row per candidate per role, with a stage from a fixed list, the stage it closed from, a reject reason that exists only while rejected, consent from the careers form and a private withdraw token. Interviews hold one scorecard per interviewer, and ratings sit in their own table keyed by scorecard and role attribute, so the app can show feedback without ever turning it into a score.
- 13 tables, 4 indexes
- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1),
- 56 seed rows from the blueprint
- The blueprint's test build passed 29 of 29 acceptance checks
Hiring pipeline entity-relationship diagram
Relationships
- roles.hiring_manager_id references people.id: each roles row points to at most one people row, and one people row can have many roles rows pointing to it.
- role_attributes.role_id references roles.id: each role_attributes row points to exactly one roles row, and one roles row can have many role_attributes rows pointing to it.
- applications.candidate_id references candidates.id: each applications row points to exactly one candidates row, and one candidates row can have many applications rows pointing to it.
- applications.role_id references roles.id: each applications row points to exactly one roles row, and one roles row can have many applications rows pointing to it.
- interviews.application_id references applications.id: each interviews row points to exactly one applications row, and one applications row can have many interviews rows pointing to it.
- interviews.created_by references people.id: each interviews row points to at most one people row, and one people row can have many interviews rows pointing to it.
- scorecards.interview_id references interviews.id: each scorecards row points to exactly one interviews row, and one interviews row can have many scorecards rows pointing to it.
- scorecards.interviewer_id references people.id: each scorecards row points to exactly one people row, and one people row can have many scorecards rows pointing to it.
- attribute_ratings.scorecard_id references scorecards.id: each attribute_ratings row points to exactly one scorecards row, and one scorecards row can have many attribute_ratings rows pointing to it.
- attribute_ratings.attribute_id references role_attributes.id: each attribute_ratings row points to exactly one role_attributes row, and one role_attributes row can have many attribute_ratings rows pointing to it.
- notes.application_id references applications.id: each notes row points to exactly one applications row, and one applications row can have many notes rows pointing to it.
- notes.author_id references people.id: each notes row points to exactly one people row, and one people row can have many notes rows pointing to it.
- events.application_id references applications.id: each events row points to at most one applications row, and one applications row can have many events rows pointing to it.
- events.actor_id 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.
- notifications.person_id references people.id: each notifications row points to at most one people row, and one people row can have many notifications rows pointing to it.
- notifications.application_id references applications.id: each notifications row points to at most one applications row, and one applications row can have many notifications rows pointing to it.
Hiring pipeline tables
The schema has 13 tables. Every column below is read from the SQL file itself. Also described as: recruitment database design, hiring pipeline database tables, ATS data model.
| Table | Implements | What a row is |
|---|---|---|
people | Person | A member of the hiring team who can sign in. |
settings | Settings | The single row with the company name, privacy notice and version, retention days and rejection template. |
roles | Role | A job with its hiring manager, location, description and status. |
role_attributes | RoleAttribute | One scorecard criterion of a role, in display order. |
candidates | Candidate | A person who applied or was added, matched by email. |
applications | Application | One candidate for one role, with its stage, source, consent and close details. |
interviews | Interview | A scheduled screen or interview on an application. |
scorecards | Scorecard | One interviewer feedback form for one interview. |
attribute_ratings | AttributeRating | One 1 to 4 rating, or Not assessed, for one attribute on a scorecard. |
notes | Note | An internal comment on an application, hidden from interviewers. |
events | Event | One line of the append-only activity log, with no candidate personal data. |
notifications | Notification | One email in the outbox, with its send status and attempts. |
apply_attempts | ApplyAttempt | One accepted careers-form submission, keyed by a hash of the IP, for the rate limit. |
people
A member of the hiring team who can sign in. People are deactivated, never deleted.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
name | TEXT | no | Check: LENGTH(name) >= 1 | ||
email | TEXT | no | Unique | stored lowercaseCheck: email = LOWER(email) | |
is_admin | BOOLEAN | no | FALSE | ||
active | BOOLEAN | no | TRUE |
- App rule (R17): deactivating a hiring manager of an open or paused role, or someone with pending scorecards, is refused; at least one active admin remains.
settings
The single settings row for the company.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | INTEGER | no | Primary key | one row onlyCheck: id = 1 | |
company_name | TEXT | no | Check: LENGTH(company_name) BETWEEN 1 AND 60 | ||
time_zone | TEXT | no | 'America/New_York' | IANA name; dates and the 08:00 digest use it | |
careers_intro | TEXT | yes | optional, top of the careers pageCheck: LENGTH(careers_intro) <= 1000 | ||
privacy_notice | TEXT | no | the text candidates acceptCheck: LENGTH(privacy_notice) BETWEEN 1 AND 2000 | ||
privacy_version | INTEGER | no | 1 | Check: privacy_version >= 1 | |
retention_days | INTEGER | no | 180 | Check: retention_days BETWEEN 30 AND 730 | |
rejection_template | TEXT | no | may use {candidate_first_name}, {role_title}, {company_name}Check: LENGTH(rejection_template) BETWEEN 1 AND 2000 | ||
last_digest_at | TIMESTAMP | yes | written only by the scheduled job |
- App rule (R15): changing privacy_notice adds 1 to privacy_version and writes a settings_changed event.
roles
A job the team is hiring for.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
title | TEXT | no | Check: LENGTH(title) BETWEEN 1 AND 100 | ||
department | TEXT | yes | optionalCheck: LENGTH(department) <= 60 | ||
location | TEXT | no | for example Remote (US)Check: LENGTH(location) BETWEEN 1 AND 80 | ||
description | TEXT | no | MarkdownCheck: LENGTH(description) BETWEEN 20 AND 5000 | ||
hiring_manager_id | TEXT | yes | References people.id | must be an active person; required to open the role | |
status | TEXT | no | 'paused' | Check: status IN ('open', 'paused', 'closed') | |
opened_at | TIMESTAMP | yes | empty until the role is first opened | ||
closed_at | TIMESTAMP | yes |
- Table check:
status <> 'open' OR (hiring_manager_id IS NOT NULL AND opened_at IS NOT NULL) - Unique index
roles_title_uniqon(LOWER(title))wherestatus <> 'closed' - App rule (R4): a role needs 3 to 6 attributes to be opened; closing a role rejects its open applications in the same action.
role_attributes
One scorecard criterion of a role.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
role_id | TEXT | no | References roles.id | ||
name | TEXT | no | Check: LENGTH(name) BETWEEN 2 AND 60 | ||
position | INTEGER | no | display order on the scorecard |
- Unique index
role_attributes_name_uniqon(role_id, LOWER(name)) - App rule (section 5): an attribute that has ratings can be renamed or reordered but not removed.
candidates
A person who applied or was added by the team.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
name | TEXT | no | Check: LENGTH(name) BETWEEN 1 AND 100 | ||
email | TEXT | yes | stored lowercase; cleared only by anonymizationCheck: LENGTH(email) <= 254 AND email = LOWER(email) | ||
phone | TEXT | yes | Check: LENGTH(phone) <= 30 | ||
link | TEXT | yes | CV, LinkedIn or portfolioCheck: LENGTH(link) <= 2000 AND link LIKE 'https://%' | ||
anonymized_at | TIMESTAMP | yes |
- Table check:
anonymized_at IS NOT NULL OR email IS NOT NULL - Unique index
candidates_email_uniqon(email)whereanonymized_at IS NULL - App rule (R14): when no application is open, hired or inside the retention window, name becomes Anonymized candidate and email, phone and link are cleared.
applications
One candidate for one role, moving through the stages.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
candidate_id | TEXT | no | References candidates.id | ||
role_id | TEXT | no | References roles.id | ||
source | TEXT | no | Check: source IN ('careers_page', 'referral', 'sourced', 'agency', 'other') | ||
source_detail | TEXT | yes | for example the referrer nameCheck: LENGTH(source_detail) <= 100 | ||
answer | TEXT | yes | Why this role? Required on the careers form, optional when the team adds a candidateCheck: LENGTH(answer) BETWEEN 1 AND 2000 | ||
consent_at | TIMESTAMP | yes | from the privacy checkbox; NULL when the team added the candidate | ||
consent_version | INTEGER | yes | the privacy_version accepted | ||
stage | TEXT | no | 'applied' | Check: stage IN ('applied', 'screen', 'interview', 'offer', 'hired', 'rejected', 'withdrawn') | |
stage_before_close | TEXT | yes | the stage when rejected or withdrawnCheck: stage_before_close IN ('applied', 'screen', 'interview', 'offer') | ||
reject_reason | TEXT | yes | Check: reject_reason IN ('requirements', 'chose_another', 'role_closed', 'no_response', 'other') | ||
close_note | TEXT | yes | Check: LENGTH(close_note) <= 500 | ||
applied_at | TIMESTAMP | no | |||
stage_changed_at | TIMESTAMP | no | |||
closed_at | TIMESTAMP | yes | set by hire, reject and withdraw | ||
withdraw_token | TEXT | no | Unique | at least 128 random bits, URL-safe (R13) | |
anonymized_at | TIMESTAMP | yes |
- Unique together:
candidate_id, role_id - Table check:
(consent_at IS NULL AND consent_version IS NULL) OR (consent_at IS NOT NULL AND consent_version IS NOT NULL) - Table check:
(stage IN ('hired', 'rejected', 'withdrawn') AND closed_at IS NOT NULL) OR (stage IN ('applied', 'screen', 'interview', 'offer') AND closed_at IS NULL) - Table check:
stage NOT IN ('rejected', 'withdrawn') OR stage_before_close IS NOT NULL - Table check:
(stage = 'rejected' AND reject_reason IS NOT NULL) OR (stage <> 'rejected' AND reject_reason IS NULL) - App rule (R6): advance and move back change the stage by exactly one step.
- App rule (R7): Interview to Offer needs a submitted scorecard and no pending ones on interviews that are not cancelled.
- App rule (R14): anonymization clears answer and close_note.
interviews
A scheduled screen or interview on an application.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
application_id | TEXT | no | References applications.id | ||
kind | TEXT | no | Check: kind IN ('screen', 'interview') | ||
starts_at | TIMESTAMP | no | |||
duration_minutes | INTEGER | yes | Check: duration_minutes BETWEEN 15 AND 240 | ||
location | TEXT | yes | a room, a phone number or a video link; required when schedulingCheck: LENGTH(location) <= 200 | ||
created_by | TEXT | yes | References people.id | who scheduled it | |
created_at | TIMESTAMP | no | |||
cancelled_at | TIMESTAMP | yes |
- App rule (section 7): 1 to 4 active interviewers, one pending scorecard each.
- App rule (R14): anonymization clears location.
scorecards
One interviewer feedback form for one interview.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
interview_id | TEXT | no | References interviews.id | ||
interviewer_id | TEXT | no | References people.id | ||
status | TEXT | no | 'pending' | Check: status IN ('pending', 'submitted', 'cancelled') | |
takeaways | TEXT | yes | Check: LENGTH(takeaways) BETWEEN 20 AND 3000 | ||
recommendation | TEXT | yes | no default; no_decision is an explicit choiceCheck: recommendation IN ('definitely_not', 'no', 'yes', 'strong_yes', 'no_decision') | ||
submitted_at | TIMESTAMP | yes | |||
reminded_at | TIMESTAMP | yes | set by the job 24 hours after the interview started |
- Unique together:
interview_id, interviewer_id - Table check:
(status = 'submitted' AND recommendation IS NOT NULL AND submitted_at IS NOT NULL) OR (status <> 'submitted' AND submitted_at IS NULL) - App rule (R10): only the assigned interviewer submits, once, after starts_at, with at least one rating and takeaways of 20 or more characters.
- App rule (R14): anonymization deletes takeaways.
attribute_ratings
One attribute rating on a scorecard.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
scorecard_id | TEXT | no | Primary key (part); References scorecards.id | ||
attribute_id | TEXT | no | Primary key (part); References role_attributes.id | ||
rating | INTEGER | yes | NULL means Not assessed; 1 Weak, 2 Mixed, 3 Good, 4 StrongCheck: rating BETWEEN 1 AND 4 |
notes
An internal comment on an application. Admins and the hiring manager only (R12).
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
application_id | TEXT | no | References applications.id | ||
author_id | TEXT | no | References people.id | ||
text | TEXT | no | Check: LENGTH(text) BETWEEN 1 AND 2000 | ||
created_at | TIMESTAMP | no |
events
One line of the activity log. Never holds candidate personal data.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
application_id | TEXT | yes | References applications.id | NULL for candidate_deleted, role and settings events | |
actor_id | TEXT | yes | References people.id | NULL for the candidate and the system | |
type | TEXT | no | Check: type IN ('applied', 'added', 'stage_changed', 'rejected', 'withdrawn', 'reopened', 'hired', 'interview_scheduled', 'interview_cancelled', 'scorecard_submitted', 'note_added', 'anonymized', 'candidate_deleted', 'role_created', 'role_changed', 'settings_changed') | ||
data | TEXT | yes | JSON text: from/to stage, reason, counts | ||
created_at | TIMESTAMP | no |
- App rule (R18): events are never edited, and only removed by Delete now (R16).
notifications
One email in the outbox, written before it is sent.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
kind | TEXT | no | the trigger from section 10; the spec gives no fixed list of values | ||
to_email | TEXT | no | |||
person_id | TEXT | yes | References people.id | NULL for candidates | |
application_id | TEXT | yes | References applications.id | ||
subject | TEXT | no | |||
body | TEXT | no | plain text | ||
status | TEXT | no | 'pending' | Check: status IN ('pending', 'sent', 'logged', 'failed') | |
error | TEXT | yes | |||
attempts | INTEGER | no | 0 | each send attempt adds 1; retries stop at 5Check: attempts >= 0 | |
created_at | TIMESTAMP | no | |||
sent_at | TIMESTAMP | yes |
apply_attempts
One accepted careers-form submission, for the rate limit (R5). Rows older than a day are deleted.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | row id; the spec lists only ip_hash and created_at | |
ip_hash | TEXT | no | HMAC of the IP address with a server secret; the IP itself is never stored | ||
created_at | TIMESTAMP | no |
- Index
apply_attempts_ip_idxon(ip_hash, created_at)
The SQL
The whole schema in one file. It runs top to bottom, unmodified, on SQLite and PostgreSQL. Download hiring-pipeline.sql or copy it from here.
-- Hiring Pipeline database schema
-- Source: https://personalsoftwarefactory.com/blueprints/hiring-pipeline (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.
-- A member of the hiring team who can sign in. People are deactivated, never deleted.
-- App rule (R17): deactivating a hiring manager of an open or paused role, or someone with pending scorecards, is refused; at least one active admin remains.
CREATE TABLE people (
id TEXT PRIMARY KEY,
name TEXT NOT NULL CHECK (LENGTH(name) >= 1),
email TEXT NOT NULL UNIQUE CHECK (email = LOWER(email)), -- stored lowercase
is_admin BOOLEAN NOT NULL DEFAULT FALSE,
active BOOLEAN NOT NULL DEFAULT TRUE
);
-- The single settings row for the company.
-- App rule (R15): changing privacy_notice adds 1 to privacy_version and writes a settings_changed event.
CREATE TABLE settings (
id INTEGER PRIMARY KEY CHECK (id = 1), -- one row only
company_name TEXT NOT NULL CHECK (LENGTH(company_name) BETWEEN 1 AND 60),
time_zone TEXT NOT NULL DEFAULT 'America/New_York', -- IANA name; dates and the 08:00 digest use it
careers_intro TEXT CHECK (LENGTH(careers_intro) <= 1000), -- optional, top of the careers page
privacy_notice TEXT NOT NULL CHECK (LENGTH(privacy_notice) BETWEEN 1 AND 2000), -- the text candidates accept
privacy_version INTEGER NOT NULL DEFAULT 1 CHECK (privacy_version >= 1),
retention_days INTEGER NOT NULL DEFAULT 180 CHECK (retention_days BETWEEN 30 AND 730),
rejection_template TEXT NOT NULL CHECK (LENGTH(rejection_template) BETWEEN 1 AND 2000), -- may use {candidate_first_name}, {role_title}, {company_name}
last_digest_at TIMESTAMP -- written only by the scheduled job
);
-- A job the team is hiring for.
-- App rule (R4): a role needs 3 to 6 attributes to be opened; closing a role rejects its open applications in the same action.
CREATE TABLE roles (
id TEXT PRIMARY KEY,
title TEXT NOT NULL CHECK (LENGTH(title) BETWEEN 1 AND 100),
department TEXT CHECK (LENGTH(department) <= 60), -- optional
location TEXT NOT NULL CHECK (LENGTH(location) BETWEEN 1 AND 80), -- for example Remote (US)
description TEXT NOT NULL CHECK (LENGTH(description) BETWEEN 20 AND 5000), -- Markdown
hiring_manager_id TEXT REFERENCES people(id), -- must be an active person; required to open the role
status TEXT NOT NULL DEFAULT 'paused' CHECK (status IN ('open', 'paused', 'closed')),
opened_at TIMESTAMP, -- empty until the role is first opened
closed_at TIMESTAMP,
CHECK (status <> 'open' OR (hiring_manager_id IS NOT NULL AND opened_at IS NOT NULL))
);
CREATE UNIQUE INDEX roles_title_uniq ON roles (LOWER(title)) WHERE status <> 'closed'; -- unique ignoring case among roles that are not closed
-- One scorecard criterion of a role.
-- App rule (section 5): an attribute that has ratings can be renamed or reordered but not removed.
CREATE TABLE role_attributes (
id TEXT PRIMARY KEY,
role_id TEXT NOT NULL REFERENCES roles(id),
name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 2 AND 60),
position INTEGER NOT NULL -- display order on the scorecard
);
CREATE UNIQUE INDEX role_attributes_name_uniq ON role_attributes (role_id, LOWER(name)); -- unique per role ignoring case
-- A person who applied or was added by the team.
-- App rule (R14): when no application is open, hired or inside the retention window, name becomes Anonymized candidate and email, phone and link are cleared.
CREATE TABLE candidates (
id TEXT PRIMARY KEY,
name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 1 AND 100),
email TEXT CHECK (LENGTH(email) <= 254 AND email = LOWER(email)), -- stored lowercase; cleared only by anonymization
phone TEXT CHECK (LENGTH(phone) <= 30),
link TEXT CHECK (LENGTH(link) <= 2000 AND link LIKE 'https://%'), -- CV, LinkedIn or portfolio
anonymized_at TIMESTAMP,
CHECK (anonymized_at IS NOT NULL OR email IS NOT NULL)
);
CREATE UNIQUE INDEX candidates_email_uniq ON candidates (email) WHERE anonymized_at IS NULL; -- unique among candidates that are not anonymized
-- One candidate for one role, moving through the stages.
-- App rule (R6): advance and move back change the stage by exactly one step.
-- App rule (R7): Interview to Offer needs a submitted scorecard and no pending ones on interviews that are not cancelled.
-- App rule (R14): anonymization clears answer and close_note.
CREATE TABLE applications (
id TEXT PRIMARY KEY,
candidate_id TEXT NOT NULL REFERENCES candidates(id),
role_id TEXT NOT NULL REFERENCES roles(id),
source TEXT NOT NULL CHECK (source IN ('careers_page', 'referral', 'sourced', 'agency', 'other')),
source_detail TEXT CHECK (LENGTH(source_detail) <= 100), -- for example the referrer name
answer TEXT CHECK (LENGTH(answer) BETWEEN 1 AND 2000), -- Why this role? Required on the careers form, optional when the team adds a candidate
consent_at TIMESTAMP, -- from the privacy checkbox; NULL when the team added the candidate
consent_version INTEGER, -- the privacy_version accepted
stage TEXT NOT NULL DEFAULT 'applied' CHECK (stage IN ('applied', 'screen', 'interview', 'offer', 'hired', 'rejected', 'withdrawn')),
stage_before_close TEXT CHECK (stage_before_close IN ('applied', 'screen', 'interview', 'offer')), -- the stage when rejected or withdrawn
reject_reason TEXT CHECK (reject_reason IN ('requirements', 'chose_another', 'role_closed', 'no_response', 'other')),
close_note TEXT CHECK (LENGTH(close_note) <= 500),
applied_at TIMESTAMP NOT NULL,
stage_changed_at TIMESTAMP NOT NULL,
closed_at TIMESTAMP, -- set by hire, reject and withdraw
withdraw_token TEXT NOT NULL UNIQUE, -- at least 128 random bits, URL-safe (R13)
anonymized_at TIMESTAMP,
UNIQUE (candidate_id, role_id),
CHECK ((consent_at IS NULL AND consent_version IS NULL) OR (consent_at IS NOT NULL AND consent_version IS NOT NULL)),
CHECK ((stage IN ('hired', 'rejected', 'withdrawn') AND closed_at IS NOT NULL) OR (stage IN ('applied', 'screen', 'interview', 'offer') AND closed_at IS NULL)),
CHECK (stage NOT IN ('rejected', 'withdrawn') OR stage_before_close IS NOT NULL),
CHECK ((stage = 'rejected' AND reject_reason IS NOT NULL) OR (stage <> 'rejected' AND reject_reason IS NULL))
);
-- A scheduled screen or interview on an application.
-- App rule (section 7): 1 to 4 active interviewers, one pending scorecard each.
-- App rule (R14): anonymization clears location.
CREATE TABLE interviews (
id TEXT PRIMARY KEY,
application_id TEXT NOT NULL REFERENCES applications(id),
kind TEXT NOT NULL CHECK (kind IN ('screen', 'interview')),
starts_at TIMESTAMP NOT NULL,
duration_minutes INTEGER CHECK (duration_minutes BETWEEN 15 AND 240),
location TEXT CHECK (LENGTH(location) <= 200), -- a room, a phone number or a video link; required when scheduling
created_by TEXT REFERENCES people(id), -- who scheduled it
created_at TIMESTAMP NOT NULL,
cancelled_at TIMESTAMP
);
-- One interviewer feedback form for one interview.
-- App rule (R10): only the assigned interviewer submits, once, after starts_at, with at least one rating and takeaways of 20 or more characters.
-- App rule (R14): anonymization deletes takeaways.
CREATE TABLE scorecards (
id TEXT PRIMARY KEY,
interview_id TEXT NOT NULL REFERENCES interviews(id),
interviewer_id TEXT NOT NULL REFERENCES people(id),
status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'submitted', 'cancelled')),
takeaways TEXT CHECK (LENGTH(takeaways) BETWEEN 20 AND 3000),
recommendation TEXT CHECK (recommendation IN ('definitely_not', 'no', 'yes', 'strong_yes', 'no_decision')), -- no default; no_decision is an explicit choice
submitted_at TIMESTAMP,
reminded_at TIMESTAMP, -- set by the job 24 hours after the interview started
UNIQUE (interview_id, interviewer_id),
CHECK ((status = 'submitted' AND recommendation IS NOT NULL AND submitted_at IS NOT NULL) OR (status <> 'submitted' AND submitted_at IS NULL))
);
-- One attribute rating on a scorecard.
CREATE TABLE attribute_ratings (
scorecard_id TEXT NOT NULL REFERENCES scorecards(id),
attribute_id TEXT NOT NULL REFERENCES role_attributes(id),
rating INTEGER CHECK (rating BETWEEN 1 AND 4), -- NULL means Not assessed; 1 Weak, 2 Mixed, 3 Good, 4 Strong
PRIMARY KEY (scorecard_id, attribute_id)
);
-- An internal comment on an application. Admins and the hiring manager only (R12).
CREATE TABLE notes (
id TEXT PRIMARY KEY,
application_id TEXT NOT NULL REFERENCES applications(id),
author_id TEXT NOT NULL REFERENCES people(id),
text TEXT NOT NULL CHECK (LENGTH(text) BETWEEN 1 AND 2000),
created_at TIMESTAMP NOT NULL
);
-- One line of the activity log. Never holds candidate personal data.
-- App rule (R18): events are never edited, and only removed by Delete now (R16).
CREATE TABLE events (
id TEXT PRIMARY KEY,
application_id TEXT REFERENCES applications(id), -- NULL for candidate_deleted, role and settings events
actor_id TEXT REFERENCES people(id), -- NULL for the candidate and the system
type TEXT NOT NULL CHECK (type IN ('applied', 'added', 'stage_changed', 'rejected', 'withdrawn', 'reopened', 'hired', 'interview_scheduled', 'interview_cancelled', 'scorecard_submitted', 'note_added', 'anonymized', 'candidate_deleted', 'role_created', 'role_changed', 'settings_changed')),
data TEXT, -- JSON text: from/to stage, reason, counts
created_at TIMESTAMP NOT NULL
);
-- One email in the outbox, written before it is sent.
CREATE TABLE notifications (
id TEXT PRIMARY KEY,
kind TEXT NOT NULL, -- the trigger from section 10; the spec gives no fixed list of values
to_email TEXT NOT NULL,
person_id TEXT REFERENCES people(id), -- NULL for candidates
application_id TEXT REFERENCES applications(id),
subject TEXT NOT NULL,
body TEXT NOT NULL, -- plain text
status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'sent', 'logged', 'failed')),
error TEXT,
attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0), -- each send attempt adds 1; retries stop at 5
created_at TIMESTAMP NOT NULL,
sent_at TIMESTAMP
);
-- One accepted careers-form submission, for the rate limit (R5). Rows older than a day are deleted.
CREATE TABLE apply_attempts (
id TEXT PRIMARY KEY, -- row id; the spec lists only ip_hash and created_at
ip_hash TEXT NOT NULL, -- HMAC of the IP address with a server secret; the IP itself is never stored
created_at TIMESTAMP NOT NULL
);
CREATE INDEX apply_attempts_ip_idx ON apply_attempts (ip_hash, created_at);Seed data
Loads the settings row, 7 people, 3 open roles with their 11 attributes, 9 candidates and 9 applications, 4 interviews, 7 scorecards (2 pending, 5 submitted), Ben Cho's 4 ratings on Sora Ito and Maya's note on Mei Chen, with T fixed at Tue 13 Oct 2026, EDT times converted to UTC and dates without a time set to 12:00 UTC. Placeholders (one fixed value per field, saying the spec leaves it to the builder): the privacy notice, role descriptions, the answer on the 4 careers-page applications, interview locations and the takeaways on the 4 submitted scorecards other than Ben Cho on Sora Ito; team emails (the spec gives none) and withdraw tokens (not random; generate real ones). Placeholder dates, which no worked example depends on: role opened_at (the date of the earliest seeded application for the role), stage_changed_at for Leo, Sora and Ari (their applied date) and Taylor (after the T-8 scorecards), interview created_at (the applied date), scorecard submitted_at (23:00 UTC on the interview day) and the note created_at (the applied date). Left empty because the spec does not give them: interview duration and created_by, and ratings on the 4 submitted scorecards other than Ben Cho on Sora Ito. Events are not seeded, because the spec does not seed them; no notifications or apply attempts either.
Download hiring-pipeline-seed.sql (56 rows). It loads with foreign keys enforced on both engines.
Load it
SQLite, into a new file:
curl -s https://personalsoftwarefactory.com/schemas/hiring-pipeline.sql https://personalsoftwarefactory.com/schemas/hiring-pipeline-seed.sql | sqlite3 hiring_pipeline.dbPostgreSQL, into a new database:
createdb hiring_pipeline && curl -s https://personalsoftwarefactory.com/schemas/hiring-pipeline.sql https://personalsoftwarefactory.com/schemas/hiring-pipeline-seed.sql | psql -v ON_ERROR_STOP=1 hiring_pipelineSQLite only enforces foreign keys when the connection asks for it: run PRAGMA foreign_keys = ON; when your app opens the database.
Design decisions
One application per candidate per role
Section 5 and R3 allow one application per candidate per role, so applications has UNIQUE (candidate_id, role_id); applying again creates nothing. Candidates are matched by lowercased email, unique among candidates that are not anonymized, which is a partial unique index so anonymized rows with a cleared email never collide.
The stage decides which close fields are set
Section 6 sets closed_at on hire, reject and withdraw and clears it on reopen, and Reject requires a reason that Reopen clears. Table checks make closed_at present exactly in the three final stages, the reject reason present exactly while rejected, and stage_before_close present for rejected and withdrawn. Moving one stage at a time (R6) and the Offer gate (R7) are cross-row rules left to the app.
Ratings are their own table, and no score is stored
From the build test · field report
Each scorecard rates the role's 3 to 6 attributes 1 to 4 or Not assessed, so attribute_ratings is keyed by scorecard and attribute with a nullable rating (NULL means Not assessed). Section 7 says the app never combines ratings into a score, so there is no total or average column. An attribute that has ratings can be renamed but not removed, which the build test found was unspecified.
Anonymization clears fields, so some required fields are nullable
From the build test · field report
R14 clears a candidate's email, phone and link, an application's answer and close note, interview locations and scorecard takeaways. Those columns are nullable with length checks, and the form rules (answer required on the careers form, location required when scheduling, takeaways required to submit) stay in the app. The build test found applications had no field to mark this, and anonymized_at was added.
A submitted scorecard always has a recommendation
Section 7 makes the recommendation required to submit with no default, and No decision is an explicit value. A table check requires a recommendation and submitted_at whenever status is submitted, and no submitted_at otherwise. One scorecard per interviewer per interview is UNIQUE (interview_id, interviewer_id).
Role titles are unique only among roles that are not closed
Section 5 makes a title unique ignoring case among roles that are not closed, so a closed Product Designer role does not block a new one. A partial unique index on LOWER(title) WHERE status <> 'closed' does exactly that. An open role also needs a hiring manager and an opened_at, which a table check enforces.
The digest stores a timestamp, the outbox counts attempts
From the build test · field report
The build test found that the digest stored only the date of its last run, while listing applications received since the previous digest needs the time, and that retries had nothing to count. settings.last_digest_at is a timestamp and notifications.attempts counts send attempts, with retries stopping at 5.
Example queries
The queries behind the tool's main screens. Each returned the same rows on both engines against the seed data.
Board: open applications by role and stage
SELECT r.title AS role, a.stage, COUNT(*) AS applications FROM applications a JOIN roles r ON r.id = a.role_id WHERE a.stage IN ('applied', 'screen', 'interview', 'offer', 'hired') GROUP BY r.title, a.stage ORDER BY r.title, CASE a.stage WHEN 'applied' THEN 1 WHEN 'screen' THEN 2 WHEN 'interview' THEN 3 WHEN 'offer' THEN 4 ELSE 5 END;On the seed data: 7 rows; Account Executive has 1 each in applied, interview and offer.
Scorecard summary per application
SELECT c.name AS candidate, SUM(CASE WHEN s.status = 'submitted' THEN 1 ELSE 0 END) AS submitted, COUNT(*) AS scorecards, SUM(CASE WHEN s.recommendation = 'strong_yes' THEN 1 ELSE 0 END) AS strong_yes, SUM(CASE WHEN s.recommendation = 'yes' THEN 1 ELSE 0 END) AS yes, SUM(CASE WHEN s.recommendation = 'no' THEN 1 ELSE 0 END) AS no, SUM(CASE WHEN s.recommendation = 'definitely_not' THEN 1 ELSE 0 END) AS definitely_not, SUM(CASE WHEN s.recommendation = 'no_decision' THEN 1 ELSE 0 END) AS no_decision FROM scorecards s JOIN interviews i ON i.id = s.interview_id JOIN applications a ON a.id = i.application_id JOIN candidates c ON c.id = a.candidate_id WHERE s.status <> 'cancelled' GROUP BY c.name ORDER BY c.name;On the seed data: 4 rows; Sora Ito has 1 of 2 submitted (Yes 1), Ari Diaz 2 of 2 (Strong yes 1, Yes 1).
Pending scorecards that block Offer (R7)
SELECT c.name AS candidate, p.name AS pending_interviewer FROM applications a JOIN candidates c ON c.id = a.candidate_id JOIN interviews i ON i.application_id = a.id AND i.cancelled_at IS NULL JOIN scorecards s ON s.interview_id = i.id AND s.status = 'pending' JOIN people p ON p.id = s.interviewer_id WHERE a.stage = 'interview' ORDER BY c.name, p.name;On the seed data: 1 row, Sora Ito with Sam Okafor pending, as in the worked example.
Ratings on one scorecard, in attribute order
SELECT ra.name AS attribute, CASE ar.rating WHEN 1 THEN '1 Weak' WHEN 2 THEN '2 Mixed' WHEN 3 THEN '3 Good' WHEN 4 THEN '4 Strong' ELSE 'Not assessed' END AS rating FROM attribute_ratings ar JOIN role_attributes ra ON ra.id = ar.attribute_id WHERE ar.scorecard_id = 's_sora_ben' ORDER BY ra.position;On the seed data: 4 rows for Ben Cho on Sora Ito, from Discovery questions (3 Good) to Coachability (4 Strong).
Closed applications due for anonymization (R14)
SELECT c.name AS candidate, r.title AS role, a.stage, a.closed_at FROM applications a JOIN candidates c ON c.id = a.candidate_id JOIN roles r ON r.id = a.role_id WHERE a.stage IN ('rejected', 'withdrawn') AND a.anonymized_at IS NULL AND a.closed_at < '2026-04-16 12:00:00' ORDER BY a.closed_at;On the seed data at T with retention 180 days: 1 row, Noor Haddad (Product Designer, rejected, closed 2026-03-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 comes from
Tables are the easy half. This schema is section 5 of the Hiring Pipeline blueprint, a free spec that also has the business rules, the screens, 4 phased build prompts and 29 acceptance checks for building the whole tool with an AI app builder. We built it from those prompts and the result passed 29 of 29 acceptance checks in a browser.
- Read the Hiring Pipeline blueprint: rules, screens, build prompts and acceptance checks
- Read the build-test field report: what the test build got wrong and what was not tested
- All database schemas
- How we test blueprints
Follow new blueprints
Every new blueprint and build test appears in the feed and in the public GitHub repository. No account, no email list.