Editorial calendar database schema

Seven tables. pieces carries the design: one row per piece of content with its status, publish date, reviewer and approval, plus two date columns that remember which publish date a reminder or overdue notice was already sent for. Table CHECKs keep the approval present exactly while a piece is scheduled or published, and overdue is computed from the date and status, never stored.

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

Copy the SQLDownload SQLDownload seed data

By Sam Claassen · From the Content Calendar blueprint · MIT licensed · Markdown version

Content calendar entity-relationship diagram

peopleidPK+ 4 more columnssettingsidPKdefault_reviewer_id→ people+ 2 more columnschannelsidPK+ 3 more columnscampaignsidPKcreated_by→ people+ 5 more columnspiecesidPKchannel_id→ channelsowner_id→ peoplecampaign_id→ campaignsreviewer_id→ peopleapproved_by→ peoplecreated_by→ people+ 12 more columnsactivitiesidPKactor_id→ people+ 5 more columnsnotificationsidPKperson_id→ peoplepiece_id→ pieces+ 6 more columnspeopleidPK+ 4 more columnssettingsidPKdefault_reviewer_id→ people+ 2 more columnschannelsidPK+ 3 more columnscampaignsidPKcreated_by→ people+ 5 more columnspiecesidPKchannel_id→ channelsowner_id→ peoplecampaign_id→ campaignsreviewer_id→ peopleapproved_by→ peoplecreated_by→ people+ 12 more columnsactivitiesidPKactor_id→ people+ 5 more columnsnotificationsidPKperson_id→ peoplepiece_id→ pieces+ 6 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

  • settings.default_reviewer_id references people.id: each settings row points to exactly one people row, and one people row can have many settings rows pointing to it.
  • campaigns.created_by references people.id: each campaigns row points to exactly one people row, and one people row can have many campaigns rows pointing to it.
  • pieces.channel_id references channels.id: each pieces row points to exactly one channels row, and one channels row can have many pieces rows pointing to it.
  • pieces.owner_id references people.id: each pieces row points to exactly one people row, and one people row can have many pieces rows pointing to it.
  • pieces.campaign_id references campaigns.id: each pieces row points to at most one campaigns row, and one campaigns row can have many pieces rows pointing to it.
  • pieces.reviewer_id references people.id: each pieces row points to at most one people row, and one people row can have many pieces rows pointing to it.
  • pieces.approved_by references people.id: each pieces row points to at most one people row, and one people row can have many pieces rows pointing to it.
  • pieces.created_by references people.id: each pieces row points to exactly one people row, and one people row can have many pieces rows pointing to it.
  • activities.actor_id references people.id: each activities row points to at most one people row, and one people row can have many activities rows pointing to it.
  • notifications.person_id references people.id: each notifications row points to exactly one people row, and one people row can have many notifications rows pointing to it.
  • notifications.piece_id references pieces.id: each notifications row points to at most one pieces row, and one pieces row can have many notifications rows pointing to it. On delete: set null.

Content calendar tables

The schema has 7 tables. Every column below is read from the SQL file itself. Also described as: content calendar database design, content planning app tables, editorial workflow schema.

TableImplementsWhat a row is
peoplePersonA writer or editor on the content team.
settingsSettingsThe single row with the team time zone, default reviewer and last digest date.
channelsChannelA place content is published, with its calendar color.
campaignsCampaignA named date range that groups pieces.
piecesPieceOne piece of content with its status, publish date and review state.
activitiesActivityOne append-only log entry for a piece.
notificationsNotificationOne in-app notification, also sent by email.

people

A writer or editor on the content team.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTno
emailTEXTnoUnique
roleTEXTnoCheck: role IN ('writer', 'editor')
activeBOOLEANnoTRUE
  • App rule (section 11): the last active editor and the default reviewer can't be demoted or deactivated; owners of unpublished pieces hand them over first.

settings

The single settings row. Comes after people because it names the default reviewer.

ColumnTypeNullDefaultKeyNotes
idINTEGERnoPrimary keyone row onlyCheck: id = 1
time_zoneTEXTnoIANA name; publish dates and "today" are in this zone
default_reviewer_idTEXTnoReferences people.idan editor; gets review requests by default (R3)
last_digest_onDATEyesthe Monday the weekly digest last went out

channels

A place content is published: Blog, Newsletter, LinkedIn and so on.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnoCheck: LENGTH(name) BETWEEN 1 AND 30
colorTEXTnohex, "#rrggbb"Check: color LIKE '#______'
activeBOOLEANnoinactive channels keep their pieces but are hidden from pickers
  • Unique index channels_name_uniq on (LOWER(name))
  • App rule (section 13): the last active channel can't be deactivated.

campaigns

A named date range that groups pieces.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnoCheck: LENGTH(name) BETWEEN 1 AND 80
starts_onDATEno
ends_onDATEno
goalTEXTyesoptionalCheck: LENGTH(goal) <= 200
created_byTEXTnoReferences people.id
created_atTIMESTAMPno
  • Table check: ends_on >= starts_on
  • Unique index campaigns_name_uniq on (LOWER(name))

pieces

One piece of content moving from idea to published. Overdue is computed, never stored (R12).

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
titleTEXTnoCheck: LENGTH(title) BETWEEN 1 AND 120
channel_idTEXTnoReferences channels.id
owner_idTEXTnoReferences people.idan active person
campaign_idTEXTyesReferences campaigns.id
statusTEXTnoCheck: status IN ('idea', 'writing', 'in_review', 'scheduled', 'published')
publish_onDATEyesempty means unscheduled (the backlog)
draft_urlTEXTyesCheck: draft_url LIKE 'http://%' OR draft_url LIKE 'https://%'
notesTEXTyesCheck: LENGTH(notes) <= 2000
reviewer_idTEXTyesReferences people.idthe editor asked to review, set on submit
submitted_atTIMESTAMPyes
approved_byTEXTyesReferences people.id
approved_atTIMESTAMPyes
published_atTIMESTAMPyes
reminded_forDATEyesthe publish_on value the due-soon reminder was sent for (R11); cleared on a move
overdue_notified_forDATEyesthe publish_on value the overdue notice was sent for (R12); cleared on a move
created_byTEXTnoReferences people.id
created_atTIMESTAMPno
updated_atTIMESTAMPno
  • Table check: status IN ('idea', 'writing') OR publish_on IS NOT NULL
  • Table check: status IN ('idea', 'writing') OR draft_url IS NOT NULL
  • Table check: status <> 'in_review' OR (reviewer_id IS NOT NULL AND submitted_at IS NOT NULL)
  • Table check: (status IN ('scheduled', 'published') AND approved_by IS NOT NULL AND approved_at IS NOT NULL) OR (status NOT IN ('scheduled', 'published') AND approved_by IS NULL AND approved_at IS NULL)
  • Table check: (status = 'published' AND published_at IS NOT NULL) OR (status <> 'published' AND published_at IS NULL)
  • Index pieces_publish_on_idx on (publish_on)
  • Index pieces_owner_idx on (owner_id, status)
  • Index pieces_campaign_idx on (campaign_id)
  • App rule (R1, R2): only the transitions in section 6; the only way into scheduled is an editor's approval from in_review.
  • App rule (R3): nobody approves or requests changes on a piece they own at that moment.
  • App rule (R4, R6, R7): sending for review and approving need a publish date of today or later; moves to past dates are refused.
  • App rule (R14): only ideas can be deleted.

activities

One append-only log entry for a piece. Never edited or deleted (R17).

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
piece_idTEXTnonot a foreign key: the deleted entry outlives its piece (section 6, Delete)
actor_idTEXTyesReferences people.idempty for the scheduled job
typeTEXTnoCheck: type IN ('created', 'edited', 'moved', 'started_writing', 'parked', 'submitted', 'withdrawn', 'approved', 'changes_requested', 'reopened', 'published', 'commented', 'reminded', 'overdue', 'deleted')
commentTEXTyes
dataTEXTyesJSON text, e.g. the from and to dates of a move, or the title of a deleted idea
created_atTIMESTAMPno
  • Index activities_piece_idx on (piece_id, created_at)

notifications

One in-app notification, also emailed.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
person_idTEXTnoReferences people.id
kindTEXTnoCheck: kind IN ('review_requested', 'approved', 'changes_requested', 'assigned', 'commented', 'due_soon', 'overdue', 'digest')
piece_idTEXTyesReferences pieces.id, on delete set nullempty for digests, and cleared if the idea is deleted
textTEXTno
created_atTIMESTAMPno
readBOOLEANnoFALSE
emailed_atTIMESTAMPyes
errorTEXTyesa failed email is retried on the next daily job
  • Index notifications_person_idx on (person_id, read, created_at)

The SQL

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

content-calendar.sql
-- Content Calendar database schema
-- Source: https://personalsoftwarefactory.com/blueprints/content-calendar (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 writer or editor on the content team.
-- App rule (section 11): the last active editor and the default reviewer can't be demoted or deactivated; owners of unpublished pieces hand them over first.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT NOT NULL UNIQUE,
  role TEXT NOT NULL CHECK (role IN ('writer', 'editor')),
  active BOOLEAN NOT NULL DEFAULT TRUE
);

-- The single settings row. Comes after people because it names the default reviewer.
CREATE TABLE settings (
  id INTEGER PRIMARY KEY CHECK (id = 1), -- one row only
  time_zone TEXT NOT NULL, -- IANA name; publish dates and "today" are in this zone
  default_reviewer_id TEXT NOT NULL REFERENCES people(id), -- an editor; gets review requests by default (R3)
  last_digest_on DATE -- the Monday the weekly digest last went out
);

-- A place content is published: Blog, Newsletter, LinkedIn and so on.
-- App rule (section 13): the last active channel can't be deactivated.
CREATE TABLE channels (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 1 AND 30),
  color TEXT NOT NULL CHECK (color LIKE '#______'), -- hex, "#rrggbb"
  active BOOLEAN NOT NULL -- inactive channels keep their pieces but are hidden from pickers
);
CREATE UNIQUE INDEX channels_name_uniq ON channels (LOWER(name)); -- unique ignoring case

-- A named date range that groups pieces.
CREATE TABLE campaigns (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 1 AND 80),
  starts_on DATE NOT NULL,
  ends_on DATE NOT NULL,
  goal TEXT CHECK (LENGTH(goal) <= 200), -- optional
  created_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL,
  CHECK (ends_on >= starts_on)
);
CREATE UNIQUE INDEX campaigns_name_uniq ON campaigns (LOWER(name)); -- unique ignoring case

-- One piece of content moving from idea to published. Overdue is computed, never stored (R12).
-- App rule (R1, R2): only the transitions in section 6; the only way into scheduled is an editor's approval from in_review.
-- App rule (R3): nobody approves or requests changes on a piece they own at that moment.
-- App rule (R4, R6, R7): sending for review and approving need a publish date of today or later; moves to past dates are refused.
-- App rule (R14): only ideas can be deleted.
CREATE TABLE pieces (
  id TEXT PRIMARY KEY,
  title TEXT NOT NULL CHECK (LENGTH(title) BETWEEN 1 AND 120),
  channel_id TEXT NOT NULL REFERENCES channels(id),
  owner_id TEXT NOT NULL REFERENCES people(id), -- an active person
  campaign_id TEXT REFERENCES campaigns(id),
  status TEXT NOT NULL CHECK (status IN ('idea', 'writing', 'in_review', 'scheduled', 'published')),
  publish_on DATE, -- empty means unscheduled (the backlog)
  draft_url TEXT CHECK (draft_url LIKE 'http://%' OR draft_url LIKE 'https://%'),
  notes TEXT CHECK (LENGTH(notes) <= 2000),
  reviewer_id TEXT REFERENCES people(id), -- the editor asked to review, set on submit
  submitted_at TIMESTAMP,
  approved_by TEXT REFERENCES people(id),
  approved_at TIMESTAMP,
  published_at TIMESTAMP,
  reminded_for DATE, -- the publish_on value the due-soon reminder was sent for (R11); cleared on a move
  overdue_notified_for DATE, -- the publish_on value the overdue notice was sent for (R12); cleared on a move
  created_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL,
  updated_at TIMESTAMP NOT NULL,
  CHECK (status IN ('idea', 'writing') OR publish_on IS NOT NULL), -- R8: in review, scheduled and published pieces keep a date
  CHECK (status IN ('idea', 'writing') OR draft_url IS NOT NULL), -- R4 and R7: a draft link to submit, unchangeable after
  CHECK (status <> 'in_review' OR (reviewer_id IS NOT NULL AND submitted_at IS NOT NULL)),
  CHECK ((status IN ('scheduled', 'published') AND approved_by IS NOT NULL AND approved_at IS NOT NULL) OR (status NOT IN ('scheduled', 'published') AND approved_by IS NULL AND approved_at IS NULL)), -- reopen and request changes clear the approval
  CHECK ((status = 'published' AND published_at IS NOT NULL) OR (status <> 'published' AND published_at IS NULL))
);
CREATE INDEX pieces_publish_on_idx ON pieces (publish_on);
CREATE INDEX pieces_owner_idx ON pieces (owner_id, status);
CREATE INDEX pieces_campaign_idx ON pieces (campaign_id);

-- One append-only log entry for a piece. Never edited or deleted (R17).
CREATE TABLE activities (
  id TEXT PRIMARY KEY,
  piece_id TEXT NOT NULL, -- not a foreign key: the deleted entry outlives its piece (section 6, Delete)
  actor_id TEXT REFERENCES people(id), -- empty for the scheduled job
  type TEXT NOT NULL CHECK (type IN ('created', 'edited', 'moved', 'started_writing', 'parked', 'submitted', 'withdrawn', 'approved', 'changes_requested', 'reopened', 'published', 'commented', 'reminded', 'overdue', 'deleted')),
  comment TEXT,
  data TEXT, -- JSON text, e.g. the from and to dates of a move, or the title of a deleted idea
  created_at TIMESTAMP NOT NULL
);
CREATE INDEX activities_piece_idx ON activities (piece_id, created_at);

-- One in-app notification, also emailed.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  person_id TEXT NOT NULL REFERENCES people(id),
  kind TEXT NOT NULL CHECK (kind IN ('review_requested', 'approved', 'changes_requested', 'assigned', 'commented', 'due_soon', 'overdue', 'digest')),
  piece_id TEXT REFERENCES pieces(id) ON DELETE SET NULL, -- empty for digests, and cleared if the idea is deleted
  text TEXT NOT NULL,
  created_at TIMESTAMP NOT NULL,
  read BOOLEAN NOT NULL DEFAULT FALSE,
  emailed_at TIMESTAMP,
  error TEXT -- a failed email is retried on the next daily job
);
CREATE INDEX notifications_person_idx ON notifications (person_id, read, created_at);

Seed data

Loads section 14 as on Tue 2026-10-13, the date of its worked examples: 6 people, the settings row, 5 channels, 2 campaigns and 19 pieces, plus this morning's daily job run (Lee's due-soon reminder and Sam's overdue notice, as 2 activities and 2 notifications with the texts from section 12). The spec gives no seed time zone, so it uses its own example, America/Chicago. Draft link URLs and the creation, submission, approval and publication times are not in the spec; they follow the blueprint's working demo, and the Pricing explainer video's link uses the demo's URL pattern because the demo omits it. No other activity history is loaded.

Download content-calendar-seed.sql (37 rows). It loads with foreign keys enforced on both engines.

Load it

SQLite, into a new file:

sqlite3
curl -s https://personalsoftwarefactory.com/schemas/content-calendar.sql https://personalsoftwarefactory.com/schemas/content-calendar-seed.sql | sqlite3 content_calendar.db

PostgreSQL, into a new database:

psql
createdb content_calendar && curl -s https://personalsoftwarefactory.com/schemas/content-calendar.sql https://personalsoftwarefactory.com/schemas/content-calendar-seed.sql | psql -v ON_ERROR_STOP=1 content_calendar

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

Design decisions

The approval is tied to the status

R1 makes an editor's approval the only way into Scheduled, and section 6 clears it on Reopen and Request changes. A CHECK requires approved_by and approved_at exactly when the status is scheduled or published. The rule that nobody approves their own piece (R3) is not a CHECK, because the owner may change after approval: an editor can take over a scheduled piece.

Reminders remember the date they were for

R11 and R12 send one due-soon reminder and one overdue notice per publish date. reminded_for and overdue_notified_for store that date; moving a piece clears them (R10), so the daily job reminds again for the new date. This also makes the job safe to run twice on the same day.

Overdue is not a column

Section 5 says overdue is computed from publish_on, today and status (R12): a date before today on anything not published, including scheduled pieces nobody marked published. Storing it would be wrong every morning until a job rewrote it, and the flag must disappear the moment a piece is published or moved.

Pieces past writing keep a date and a draft link

From the build test · field report

R8 refuses to unschedule a piece in review or scheduled, and R4 needs a draft link to send for review. R7 then refuses edits to in-review and scheduled pieces, and published pieces can't be edited. CHECKs require publish_on and draft_url for every status after writing. The build test found that a piece in review or scheduled could still be edited without another review; R7 now refuses that, so the draft link can't be removed after submission.

Activity outlives deleted ideas

Deleting an idea writes a deleted activity with the title (section 6), and activity rows are never deleted (R17). activities.piece_id is therefore a plain column, not a foreign key, so the log survives the piece. Notifications about a deleted idea keep their text and lose only the link (ON DELETE SET NULL).

Names unique ignoring case

Channel names (up to 30 characters) and campaign names (up to 80) are unique ignoring case in section 5. Unique indexes on LOWER(name) enforce it on both engines, so Blog and blog can't both exist.

Example queries

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

Publishing in the next 7 days (digest)

SQL
SELECT p.publish_on, p.title, c.name AS channel, p.status, o.name AS owner, CASE WHEN p.status IN ('scheduled', 'published') THEN '' ELSE 'not approved yet' END AS flag FROM pieces p JOIN channels c ON c.id = p.channel_id JOIN people o ON o.id = p.owner_id WHERE p.publish_on BETWEEN '2026-10-13' AND '2026-10-19' ORDER BY p.publish_on, p.title;

On the seed data for the week of Tue 2026-10-13: 7 rows, matching section 9's worked example, from Launch thread: new pricing (X, scheduled) to Olsen & Co (LinkedIn, scheduled).

Pipeline board counts

SQL
SELECT status, COUNT(*) AS pieces FROM pieces GROUP BY status ORDER BY CASE status WHEN 'idea' THEN 1 WHEN 'writing' THEN 2 WHEN 'in_review' THEN 3 WHEN 'scheduled' THEN 4 ELSE 5 END;

On the seed data: 5 rows, 5 idea, 5 writing, 2 in review, 4 scheduled, 3 published, as section 14 counts.

Review queue for Maya Chen

SQL
SELECT p.title, o.name AS owner, p.publish_on, p.submitted_at, p.draft_url FROM pieces p JOIN people o ON o.id = p.owner_id WHERE p.status = 'in_review' AND p.owner_id <> 'person_maya' ORDER BY p.submitted_at;

On the seed data: 2 rows, October newsletter (sent 2 days ago) before New pricing FAQ (sent 1 day ago).

Overdue pieces

SQL
SELECT p.title, p.publish_on, p.status, o.name AS owner FROM pieces p JOIN people o ON o.id = p.owner_id WHERE p.publish_on < '2026-10-13' AND p.status <> 'published' ORDER BY p.publish_on;

On the seed data on 2026-10-13: 1 row, Acme case study video, due 2026-10-12, writing, Sam Okafor.

Campaign progress

SQL
SELECT c.name, c.starts_on, c.ends_on, SUM(CASE WHEN p.status = 'published' THEN 1 ELSE 0 END) AS published, COUNT(p.id) AS pieces, SUM(CASE WHEN p.publish_on < c.starts_on OR p.publish_on > c.ends_on THEN 1 ELSE 0 END) AS outside_dates FROM campaigns c LEFT JOIN pieces p ON p.campaign_id = c.id GROUP BY c.id, c.name, c.starts_on, c.ends_on ORDER BY c.starts_on;

On the seed data: 2 rows, Customer stories 1 of 5 published and Q4 pricing launch 1 of 5 published, none outside their dates.

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 Content Calendar blueprint, a free spec that also has the business rules, the screens, 4 phased build prompts and 27 acceptance checks for building the whole tool with an AI app builder. We built it from those prompts and the result passed 27 of 27 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.