Customer feedback management system database schema

Eleven tables. feedback holds each customer's own words and links to at most one theme; themes carries the roadmap status once promoted; votes allows one vote per account per theme. Evidence, accounts and MRR are computed from linked feedback every time, counting each account's MRR once per theme, and follow_ups lists the accounts to tell when a theme ships.

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

Copy the SQLDownload SQLDownload seed data

By Sam Claassen · From the Customer Feedback Inbox blueprint · MIT licensed · Markdown version

Customer feedback inbox entity-relationship diagram

peopleidPK+ 4 more columnssettingsidPK+ 3 more columnscustomersidPK+ 3 more columnscustomer_domainsdomainPKcustomer_id→ customersthemesidPKcreated_by→ peopleowner_id→ people+ 5 more columnsfeedbackidPKcustomer_id→ customerscaptured_by→ peopletheme_id→ themes+ 9 more columnsvotestheme_idPK → themescustomer_idPK → customersrecorded_by→ people+ 1 more columnstatus_changesidPKtheme_id→ themesactor_id→ people+ 4 more columnsfollow_upsidPKtheme_id→ themesshipped_change_id→ status_chan…customer_id→ customersdone_by→ people+ 3 more columnseventsidPKactor_id→ peopletheme_id→ themes+ 4 more columnsnotificationsidPKperson_id→ peopletheme_id→ themes+ 8 more columnspeopleidPK+ 4 more columnssettingsidPK+ 3 more columnscustomersidPK+ 3 more columnscustomer_domainsdomainPKcustomer_id→ customersthemesidPKcreated_by→ peopleowner_id→ people+ 5 more columnsfeedbackidPKcustomer_id→ customerscaptured_by→ peopletheme_id→ themes+ 9 more columnsvotestheme_idPK → themescustomer_idPK → customersrecorded_by→ people+ 1 more columnstatus_changesidPKtheme_id→ themesactor_id→ people+ 4 more columnsfollow_upsidPKtheme_id→ themesshipped_change_id→ status_chan…customer_id→ customersdone_by→ people+ 3 more columnseventsidPKactor_id→ peopletheme_id→ themes+ 4 more columnsnotificationsidPKperson_id→ peopletheme_id→ themes+ 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

  • customer_domains.customer_id references customers.id: each customer_domains row points to exactly one customers row, and one customers row can have many customer_domains rows pointing to it.
  • themes.created_by references people.id: each themes row points to exactly one people row, and one people row can have many themes rows pointing to it.
  • themes.owner_id references people.id: each themes row points to at most one people row, and one people row can have many themes rows pointing to it.
  • feedback.customer_id references customers.id: each feedback row points to at most one customers row, and one customers row can have many feedback rows pointing to it.
  • feedback.captured_by references people.id: each feedback row points to at most one people row, and one people row can have many feedback rows pointing to it.
  • feedback.theme_id references themes.id: each feedback row points to at most one themes row, and one themes row can have many feedback rows pointing to it.
  • votes.theme_id references themes.id: each votes row points to exactly one themes row, and one themes row can have many votes rows pointing to it.
  • votes.customer_id references customers.id: each votes row points to exactly one customers row, and one customers row can have many votes rows pointing to it.
  • votes.recorded_by references people.id: each votes row points to exactly one people row, and one people row can have many votes rows pointing to it.
  • status_changes.theme_id references themes.id: each status_changes row points to exactly one themes row, and one themes row can have many status_changes rows pointing to it.
  • status_changes.actor_id references people.id: each status_changes row points to exactly one people row, and one people row can have many status_changes rows pointing to it.
  • follow_ups.theme_id references themes.id: each follow_ups row points to exactly one themes row, and one themes row can have many follow_ups rows pointing to it.
  • follow_ups.shipped_change_id references status_changes.id: each follow_ups row points to exactly one status_changes row, and one status_changes row can have many follow_ups rows pointing to it.
  • follow_ups.customer_id references customers.id: each follow_ups row points to exactly one customers row, and one customers row can have many follow_ups rows pointing to it.
  • follow_ups.done_by references people.id: each follow_ups row points to at most one people row, and one people row can have many follow_ups 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.
  • events.theme_id references themes.id: each events row points to at most one themes row, and one themes 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.theme_id references themes.id: each notifications row points to at most one themes row, and one themes row can have many notifications rows pointing to it.

Customer feedback inbox tables

The schema has 11 tables. Every column below is read from the SQL file itself. Also described as: feature request tracker database design, product feedback database tables, voice of the customer SQL schema.

TableImplementsWhat a row is
peoplePersonA team member who can sign in, admin or not.
settingsSettingsThe single row with the company name, time zone and follow-up email template.
customersCustomerA customer account with its current MRR in cents.
customer_domainschild table of CustomerOne email domain that belongs to one customer, used to match inbound feedback.
themesThemeA request or problem that feedback is grouped under, with its owner and roadmap status once promoted.
feedbackFeedbackOne piece of customer feedback in their own words, with its source, sender, account and state.
votesVoteOne customer account's vote for one theme.
status_changesStatusChangeOne append-only roadmap decision on a theme, with its note.
follow_upsFollowUpOne account to tell about one shipment of a theme, and whether that was done.
eventsEventOne append-only activity entry about feedback or a theme.
notificationsNotificationOne email in the outbox, with its send status.

people

A team member who can sign in.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTno
emailTEXTnoUniquestored lowercaseCheck: email = LOWER(email)
is_adminBOOLEANnoFALSE
activeBOOLEANnoTRUE

settings

The single settings row.

ColumnTypeNullDefaultKeyNotes
idINTEGERno1Primary keyalways 1, so there can only be one rowCheck: id = 1
company_nameTEXTnoCheck: LENGTH(company_name) <= 60
time_zoneTEXTno'America/New_York'IANA name
follow_up_templateTEXTnomay use {contact_first_name}, {theme_name}, {company_name}Check: LENGTH(follow_up_template) <= 2000

customers

A customer account.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnounique ignoring case (index below)Check: LENGTH(name) BETWEEN 1 AND 80
mrr_centsINTEGERno0Check: mrr_cents >= 0
archivedBOOLEANnoFALSE
  • Unique index customers_name_unique on (LOWER(name))
  • App rule (section 12): archived customers can't vote, receive new captures or join a new follow-up list.

customer_domains

One email domain of a customer (Customer.domains in the spec). A customer may have none.

ColumnTypeNullDefaultKeyNotes
domainTEXTnoPrimary keye.g. acme.example; belongs to at most one customerCheck: domain = LOWER(domain) AND domain NOT LIKE '%@%'
customer_idTEXTnoReferences customers.id
  • Index customer_domains_customer on (customer_id)

themes

A theme: a request or problem that feedback is grouped under. Never deleted.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnounique ignoring case and surrounding spaces (index below)Check: LENGTH(TRIM(name)) BETWEEN 3 AND 80
descriptionTEXTyesCheck: description IS NULL OR LENGTH(description) <= 1000
created_byTEXTnoReferences people.id
created_atTIMESTAMPnoCURRENT_TIMESTAMP
promoted_atTIMESTAMPyesnull until promoted to the roadmap; never un-promoted
owner_idTEXTyesReferences people.idrequired once promoted
statusTEXTyesnull until promotedCheck: status IN ('under_review', 'planned', 'in_progress', 'shipped', 'not_planned')
  • Table check: promoted_at IS NULL OR owner_id IS NOT NULL
  • Table check: (promoted_at IS NULL AND status IS NULL) OR (promoted_at IS NOT NULL AND status IS NOT NULL)
  • Unique index themes_name_unique on (LOWER(TRIM(name)))
  • App rule (R7): promotion needs at least one linked feedback and an active owner.

feedback

One piece of feedback: a customer's own words. Never edited after capture (R1).

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
customer_idTEXTyesReferences customers.idnull: Needs customer
sourceTEXTnoCheck: source IN ('email', 'call', 'ticket', 'chat', 'in_app', 'other')
from_nameTEXTyesCheck: from_name IS NULL OR LENGTH(from_name) <= 100
from_emailTEXTyesstored lowercaseCheck: from_email IS NULL OR (from_email = LOWER(from_email) AND from_email LIKE '%_@_%')
quoteTEXTnonever rewrittenCheck: LENGTH(TRIM(quote)) BETWEEN 10 AND 3000
received_atTIMESTAMPnoCURRENT_TIMESTAMP
captured_byTEXTyesReferences people.idnull for inbound
external_idTEXTyesUniqueset by the inbound endpointCheck: external_id IS NULL OR LENGTH(external_id) <= 200
stateTEXTno'inbox'Check: state IN ('inbox', 'linked', 'dismissed')
theme_idTEXTyesReferences themes.idone theme at most (R2)
dismiss_reasonTEXTyesCheck: dismiss_reason IS NULL OR LENGTH(dismiss_reason) BETWEEN 5 AND 300
created_atTIMESTAMPnoCURRENT_TIMESTAMP
  • Table check: (state = 'linked' AND theme_id IS NOT NULL) OR (state <> 'linked' AND theme_id IS NULL)
  • Table check: (state = 'dismissed' AND dismiss_reason IS NOT NULL) OR (state <> 'dismissed' AND dismiss_reason IS NULL)
  • Table check: state <> 'linked' OR customer_id IS NOT NULL
  • Index feedback_theme on (theme_id)
  • Index feedback_customer on (customer_id)
  • App rule (R4): received_at is never in the future; the customer is not archived at capture.

votes

One customer account's vote for a theme. A vote never adds evidence or MRR.

ColumnTypeNullDefaultKeyNotes
theme_idTEXTnoPrimary key (part); References themes.id
customer_idTEXTnoPrimary key (part); References customers.id
recorded_byTEXTnoReferences people.id
created_atTIMESTAMPnoCURRENT_TIMESTAMP

status_changes

One status decision on a promoted theme. Append-only.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
theme_idTEXTnoReferences themes.id
from_statusTEXTyesnull for the promotionCheck: from_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'not_planned')
to_statusTEXTnoCheck: to_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'not_planned')
noteTEXTnoCheck: LENGTH(note) BETWEEN 5 AND 500
actor_idTEXTnoReferences people.id
created_atTIMESTAMPnoCURRENT_TIMESTAMP
  • Table check: from_status IS NULL OR from_status <> to_status
  • Index status_changes_theme on (theme_id, created_at)
  • App rule (R8): made by the theme owner or an admin.

follow_ups

One account to tell about one shipment of a theme.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
theme_idTEXTnoReferences themes.id
shipped_change_idTEXTnoReferences status_changes.idthe change that moved the theme to shipped
customer_idTEXTnoReferences customers.id
statusTEXTno'pending'Check: status IN ('pending', 'emailed', 'contacted', 'cancelled')
done_byTEXTyesReferences people.id
done_atTIMESTAMPyes
noteTEXTyeshow they were contactedCheck: note IS NULL OR LENGTH(note) <= 300
  • Unique together: shipped_change_id, customer_id
  • Table check: status NOT IN ('emailed', 'contacted') OR (done_by IS NOT NULL AND done_at IS NOT NULL)
  • Table check: status <> 'contacted' OR COALESCE(LENGTH(note), 0) >= 3
  • App rule (R9): created when the theme enters shipped; pending ones become cancelled when it leaves shipped.
  • App rule (R10): only the theme owner or an admin marks one emailed or contacted, once.

events

One entry in the activity log. Append-only, never updated or deleted (R15). feedback_id has no foreign key on purpose: R14 deletes feedback, and its feedback_deleted event keeps the id.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
actor_idTEXTyesReferences people.idnull for inbound and the system
feedback_idTEXTyes
theme_idTEXTyesReferences themes.id
typeTEXTnoCheck: type IN ('captured', 'inbound_received', 'customer_assigned', 'linked', 'unlinked', 'dismissed', 'restored', 'theme_created', 'vote_added', 'vote_removed', 'promoted', 'status_changed', 'owner_changed', 'follow_up_emailed', 'follow_up_contacted', 'feedback_deleted', 'customer_changed')
dataTEXTyesJSON text; cancelled follow-ups are listed in the status_changed event that left shipped
created_atTIMESTAMPnoCURRENT_TIMESTAMP
  • Index events_theme on (theme_id, created_at)

notifications

One email in the outbox, written before it is sent.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
kindTEXTno
to_emailTEXTno
person_idTEXTyesReferences people.idnull for customer contacts
theme_idTEXTyesReferences themes.id
subjectTEXTno
bodyTEXTnoplain text
statusTEXTno'pending'logged: no email provider configuredCheck: status IN ('pending', 'sent', 'logged', 'failed')
errorTEXTyes
created_atTIMESTAMPnoCURRENT_TIMESTAMP
sent_atTIMESTAMPyes
  • App rule (section 10): failed sends are retried up to 5 times after the first attempt; pending for 15 minutes counts as failed.

The SQL

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

feedback-inbox.sql
-- Customer Feedback Inbox database schema
-- Source: https://personalsoftwarefactory.com/blueprints/feedback-inbox (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 team member who can sign in.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  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.
CREATE TABLE settings (
  id INTEGER PRIMARY KEY DEFAULT 1 CHECK (id = 1), -- always 1, so there can only be one row
  company_name TEXT NOT NULL CHECK (LENGTH(company_name) <= 60),
  time_zone TEXT NOT NULL DEFAULT 'America/New_York', -- IANA name
  follow_up_template TEXT NOT NULL CHECK (LENGTH(follow_up_template) <= 2000) -- may use {contact_first_name}, {theme_name}, {company_name}
);

-- A customer account.
-- App rule (section 12): archived customers can't vote, receive new captures or join a new follow-up list.
CREATE TABLE customers (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 1 AND 80), -- unique ignoring case (index below)
  mrr_cents INTEGER NOT NULL DEFAULT 0 CHECK (mrr_cents >= 0),
  archived BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE UNIQUE INDEX customers_name_unique ON customers (LOWER(name));

-- One email domain of a customer (Customer.domains in the spec). A customer may have none.
CREATE TABLE customer_domains (
  domain TEXT PRIMARY KEY CHECK (domain = LOWER(domain) AND domain NOT LIKE '%@%'), -- e.g. acme.example; belongs to at most one customer
  customer_id TEXT NOT NULL REFERENCES customers(id)
);

CREATE INDEX customer_domains_customer ON customer_domains (customer_id);

-- A theme: a request or problem that feedback is grouped under. Never deleted.
-- App rule (R7): promotion needs at least one linked feedback and an active owner.
CREATE TABLE themes (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (LENGTH(TRIM(name)) BETWEEN 3 AND 80), -- unique ignoring case and surrounding spaces (index below)
  description TEXT CHECK (description IS NULL OR LENGTH(description) <= 1000),
  created_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  promoted_at TIMESTAMP, -- null until promoted to the roadmap; never un-promoted
  owner_id TEXT REFERENCES people(id), -- required once promoted
  status TEXT CHECK (status IN ('under_review', 'planned', 'in_progress', 'shipped', 'not_planned')), -- null until promoted
  CHECK (promoted_at IS NULL OR owner_id IS NOT NULL),
  CHECK ((promoted_at IS NULL AND status IS NULL) OR (promoted_at IS NOT NULL AND status IS NOT NULL))
);

CREATE UNIQUE INDEX themes_name_unique ON themes (LOWER(TRIM(name)));

-- One piece of feedback: a customer's own words. Never edited after capture (R1).
-- App rule (R4): received_at is never in the future; the customer is not archived at capture.
CREATE TABLE feedback (
  id TEXT PRIMARY KEY,
  customer_id TEXT REFERENCES customers(id), -- null: Needs customer
  source TEXT NOT NULL CHECK (source IN ('email', 'call', 'ticket', 'chat', 'in_app', 'other')),
  from_name TEXT CHECK (from_name IS NULL OR LENGTH(from_name) <= 100),
  from_email TEXT CHECK (from_email IS NULL OR (from_email = LOWER(from_email) AND from_email LIKE '%_@_%')), -- stored lowercase
  quote TEXT NOT NULL CHECK (LENGTH(TRIM(quote)) BETWEEN 10 AND 3000), -- never rewritten
  received_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  captured_by TEXT REFERENCES people(id), -- null for inbound
  external_id TEXT UNIQUE CHECK (external_id IS NULL OR LENGTH(external_id) <= 200), -- set by the inbound endpoint
  state TEXT NOT NULL DEFAULT 'inbox' CHECK (state IN ('inbox', 'linked', 'dismissed')),
  theme_id TEXT REFERENCES themes(id), -- one theme at most (R2)
  dismiss_reason TEXT CHECK (dismiss_reason IS NULL OR LENGTH(dismiss_reason) BETWEEN 5 AND 300),
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CHECK ((state = 'linked' AND theme_id IS NOT NULL) OR (state <> 'linked' AND theme_id IS NULL)), -- theme only when linked
  CHECK ((state = 'dismissed' AND dismiss_reason IS NOT NULL) OR (state <> 'dismissed' AND dismiss_reason IS NULL)), -- reason only when dismissed
  CHECK (state <> 'linked' OR customer_id IS NOT NULL) -- R3: evidence needs an account
);

CREATE INDEX feedback_theme ON feedback (theme_id);
CREATE INDEX feedback_customer ON feedback (customer_id);

-- One customer account's vote for a theme. A vote never adds evidence or MRR.
CREATE TABLE votes (
  theme_id TEXT NOT NULL REFERENCES themes(id),
  customer_id TEXT NOT NULL REFERENCES customers(id),
  recorded_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (theme_id, customer_id) -- one vote per account per theme (R6)
);

-- One status decision on a promoted theme. Append-only.
-- App rule (R8): made by the theme owner or an admin.
CREATE TABLE status_changes (
  id TEXT PRIMARY KEY,
  theme_id TEXT NOT NULL REFERENCES themes(id),
  from_status TEXT CHECK (from_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'not_planned')), -- null for the promotion
  to_status TEXT NOT NULL CHECK (to_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'not_planned')),
  note TEXT NOT NULL CHECK (LENGTH(note) BETWEEN 5 AND 500),
  actor_id TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CHECK (from_status IS NULL OR from_status <> to_status) -- R8: a different status
);

CREATE INDEX status_changes_theme ON status_changes (theme_id, created_at);

-- One account to tell about one shipment of a theme.
-- App rule (R9): created when the theme enters shipped; pending ones become cancelled when it leaves shipped.
-- App rule (R10): only the theme owner or an admin marks one emailed or contacted, once.
CREATE TABLE follow_ups (
  id TEXT PRIMARY KEY,
  theme_id TEXT NOT NULL REFERENCES themes(id),
  shipped_change_id TEXT NOT NULL REFERENCES status_changes(id), -- the change that moved the theme to shipped
  customer_id TEXT NOT NULL REFERENCES customers(id),
  status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'emailed', 'contacted', 'cancelled')),
  done_by TEXT REFERENCES people(id),
  done_at TIMESTAMP,
  note TEXT CHECK (note IS NULL OR LENGTH(note) <= 300), -- how they were contacted
  UNIQUE (shipped_change_id, customer_id),
  CHECK (status NOT IN ('emailed', 'contacted') OR (done_by IS NOT NULL AND done_at IS NOT NULL)),
  CHECK (status <> 'contacted' OR COALESCE(LENGTH(note), 0) >= 3) -- R10: Mark contacted needs a note
);

-- One entry in the activity log. Append-only, never updated or deleted (R15).
-- feedback_id has no foreign key on purpose: R14 deletes feedback, and its feedback_deleted event keeps the id.
CREATE TABLE events (
  id TEXT PRIMARY KEY,
  actor_id TEXT REFERENCES people(id), -- null for inbound and the system
  feedback_id TEXT,
  theme_id TEXT REFERENCES themes(id),
  type TEXT NOT NULL CHECK (type IN ('captured', 'inbound_received', 'customer_assigned', 'linked', 'unlinked', 'dismissed', 'restored', 'theme_created', 'vote_added', 'vote_removed', 'promoted', 'status_changed', 'owner_changed', 'follow_up_emailed', 'follow_up_contacted', 'feedback_deleted', 'customer_changed')),
  data TEXT, -- JSON text; cancelled follow-ups are listed in the status_changed event that left shipped
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX events_theme ON events (theme_id, created_at);

-- One email in the outbox, written before it is sent.
-- App rule (section 10): failed sends are retried up to 5 times after the first attempt; pending for 15 minutes counts as failed.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  kind TEXT NOT NULL,
  to_email TEXT NOT NULL,
  person_id TEXT REFERENCES people(id), -- null for customer contacts
  theme_id TEXT REFERENCES themes(id),
  subject TEXT NOT NULL,
  body TEXT NOT NULL, -- plain text
  status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'sent', 'logged', 'failed')), -- logged: no email provider configured
  error TEXT,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  sent_at TIMESTAMP
);

Seed data

Loads section 14 with T fixed to Wed 14 Oct 2026: 5 people, the settings row with the follow-up template, 4 customers and their 4 domains, 3 themes, feedback F1 to F5, 2 votes, the 5 status changes, Ridgeway's pending follow-up for CSV export, and 15 events for the captures, inbound items, theme creations, promotions, status changes and votes. The spec names who did each of those but not who linked F1 to F4, so the four linked events are left out rather than given a made-up actor. Received dates are midnight team time as R4 defines; theme creation dates (the day of each theme's first feedback), vote dates (start of T) and times of day are placeholders the spec doesn't give. The outbox is empty, as the spec says.

Download feedback-inbox-seed.sql (45 rows). It loads with foreign keys enforced on both engines.

Load it

SQLite, into a new file:

sqlite3
curl -s https://personalsoftwarefactory.com/schemas/feedback-inbox.sql https://personalsoftwarefactory.com/schemas/feedback-inbox-seed.sql | sqlite3 feedback_inbox.db

PostgreSQL, into a new database:

psql
createdb feedback_inbox && curl -s https://personalsoftwarefactory.com/schemas/feedback-inbox.sql https://personalsoftwarefactory.com/schemas/feedback-inbox-seed.sql | psql -v ON_ERROR_STOP=1 feedback_inbox

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

Design decisions

Theme metrics are computed, never stored

Section 6 computes Evidence, Accounts, MRR and Votes from the rows every time. MRR sums each distinct account's current mrr_cents once per theme, so two quotes from Acme add $2,400 once, and a vote never adds evidence or MRR. A stored running total would go stale the moment an admin corrects an account's MRR (R12).

Feedback state, theme and reason must agree

CHECK constraints require theme_id exactly when state is linked, dismiss_reason exactly when state is dismissed, and a customer before anything is linked (R3: evidence needs an account). Linking to another theme replaces theme_id, so a piece of feedback is evidence for one theme at most (R2).

Domains are a child table keyed by the domain

Section 5 says each domain belongs to at most one customer and a customer may have none. customer_domains uses the domain as its primary key, which enforces that rule across customers, and the inbound endpoint (section 11) matches a sender's exact domain with one indexed lookup. A comma-separated column could not stop two customers claiming acme.example.

Names are unique ignoring case

Customer names are unique ignoring case and theme names ignoring case and surrounding spaces (section 5, R5). Both use a unique index on LOWER(name), with TRIM for themes, so "single sign-on " cannot sit beside "Single sign-on". A plain UNIQUE would compare case on PostgreSQL and let duplicates through.

Promotion sets owner and status together

A theme has no status until it is promoted, and needs an owner once it is (section 5). CHECK constraints keep promoted_at and status both null or both set, and require owner_id once promoted. Evidence before promotion (R7) spans tables and stays in the app.

Events keep the id of deleted feedback

From the build test · field report

An admin can delete a piece of feedback when a customer asks for their words to be removed, and the feedback_deleted event keeps only the id, the account and the theme (R14). events.feedback_id therefore has no foreign key. Our build test found the spec had no event type for cancelled follow-ups or people and settings changes; section 5 now records cancellations in the data of the status_changed event that left Shipped and logs no people or settings changes in v1.

A follow-up list belongs to one shipment

From the build test · field report

follow_ups references the status change that moved the theme to Shipped and is unique per (shipped_change_id, customer_id), so shipping again starts a new list while earlier ones stay as history (R9). Our build test found cancelled follow-ups could not be seen after a theme left Shipped; earlier lists now stay visible with each follow-up's status. A CHECK requires who and when for emailed and contacted, and a note for contacted (R10).

Example queries

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

Themes ranked by evidence, with accounts, MRR and votes

SQL
SELECT
  t.name,
  t.status,
  (SELECT COUNT(*) FROM feedback f WHERE f.theme_id = t.id AND f.state = 'linked') AS evidence,
  (SELECT COUNT(DISTINCT f.customer_id) FROM feedback f WHERE f.theme_id = t.id AND f.state = 'linked') AS accounts,
  (SELECT COALESCE(SUM(c.mrr_cents), 0) FROM customers c WHERE c.id IN (SELECT f.customer_id FROM feedback f WHERE f.theme_id = t.id AND f.state = 'linked')) AS mrr_cents,
  (SELECT COUNT(*) FROM votes v WHERE v.theme_id = t.id) AS votes
FROM themes t
ORDER BY evidence DESC, t.name;

On the seed data: 3 rows, matching section 6. Single sign-on has 2 evidence, 1 account, 240000 cents ($2,400) and 2 votes; CSV export and Slack alerts tie at 1 and sort by name.

Inbox tab counts

SQL
SELECT
  CASE WHEN state = 'inbox' AND customer_id IS NULL THEN 'Needs customer' WHEN state = 'inbox' THEN 'Inbox' WHEN state = 'linked' THEN 'Linked' ELSE 'Dismissed' END AS tab,
  COUNT(*) AS items
FROM feedback
GROUP BY CASE WHEN state = 'inbox' AND customer_id IS NULL THEN 'Needs customer' WHEN state = 'inbox' THEN 'Inbox' WHEN state = 'linked' THEN 'Linked' ELSE 'Dismissed' END
ORDER BY tab;

On the seed data: 2 rows, Inbox 1 (Harbor Studio's call) and Linked 4. Tabs with no items return no row.

Roadmap cards by lane

SQL
SELECT
  t.status,
  t.name,
  p.name AS owner,
  (SELECT COUNT(*) FROM feedback f WHERE f.theme_id = t.id AND f.state = 'linked') AS evidence
FROM themes t
JOIN people p ON p.id = t.owner_id
WHERE t.promoted_at IS NOT NULL
ORDER BY t.status, evidence DESC, t.name;

On the seed data: 2 rows. Single sign-on is planned, owned by Sam Okafor; CSV export is shipped, owned by Maya Chen.

Pending follow-ups with their contact addresses

SQL
SELECT t.name AS theme, c.name AS customer, sc.created_at AS shipped_at, f.from_email
FROM follow_ups fu
JOIN themes t ON t.id = fu.theme_id
JOIN customers c ON c.id = fu.customer_id
JOIN status_changes sc ON sc.id = fu.shipped_change_id
LEFT JOIN feedback f ON f.theme_id = fu.theme_id AND f.customer_id = fu.customer_id AND f.state = 'linked' AND f.from_email IS NOT NULL
WHERE fu.status = 'pending'
ORDER BY sc.created_at, c.name, f.from_email;

On the seed data: 1 row, CSV export for Ridgeway, to ella@ridgeway.example. An account with no address on the theme returns a null from_email and can only be marked contacted (R10).

A theme's status history

SQL
SELECT sc.from_status, sc.to_status, sc.note, p.name AS actor, sc.created_at
FROM status_changes sc
JOIN themes t ON t.id = sc.theme_id
JOIN people p ON p.id = sc.actor_id
WHERE t.name = 'CSV export'
ORDER BY sc.created_at;

On the seed data: 3 rows for CSV export, from the promotion to under_review through in_progress ("Started") to shipped ("Released in version 2.14"), all by Maya Chen.

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