Capstone 1: Build Your First Business Database
Build the non-AI core of SignalDesk as a complete, reproducible PostgreSQL database. Starting from business rules, create organizations, users, memberships, customers, tickets, messages, tags, assignments, and audit events; then prove constraints, SQL reports, transactions, tenant ownership, rollback, and restore. The deliverable is evidence and reasoning, not only a schema file.
What will you be able to do?
- Convert requirements into an ERD and invariant catalog.
- Deliver versioned DDL, seed data, queries, and negative tests.
- Demonstrate atomic workflows and tenant-safe relationships.
- Restore the database and validate it independently.
Prerequisites and mental model
Complete Parts 1–5. Work in an isolated database. Treat the capstone as a miniature production delivery with source control, reproducible commands, and a review packet.
Requirements
The system must support:
- users in multiple organizations with membership roles/status;
- tenant-local customers and unique emails;
- tickets with state, priority, assignee, optimistic version, and timestamps;
- ordered messages with customer/agent/system authorship;
- tenant-owned tags and assignments;
- append-only ticket events for assignment and state change;
- deletion/retention behavior documented for every relationship.
Required queries:
- stable paginated active inbox;
- one row per ticket with customer, message count, and latest message;
- tickets without agent response;
- daily status report in a declared zone;
- top issue tags without join double-counting.
Build sequence
- Write row predicates, keys, cardinalities, and forbidden states.
- Draw ERD and choose type/time/delete semantics.
- Create numbered forward migrations.
- Seed two tenants with overlapping labels and adversarial null/tie cases.
- Write positive and negative constraint tests.
- Implement queries with expected result fixtures.
- Demonstrate one atomic assignment workflow and stale-version rejection.
- Dump and restore into a different database.
- Produce a concise architecture decision record.
Why does this matter in AI-native systems?
This database becomes the trustworthy substrate for later retrieval and tools. If tenant ownership, event history, state transitions, time, or concurrency is ambiguous here, AI will amplify the ambiguity rather than repair it.
Prove it worked: rubric
Any cross-tenant acceptance is an automatic fail.
Common mistakes
- Schema first, rules later: constraints miss domain → approve invariant catalog first.
- Happy data only: defects remain invisible → seed collisions, ties, nulls, zero/many children.
- Screenshot as evidence: not reproducible → submit commands, queries, outputs, and checksums.
AI Pair-Programmer Prompt
Hands-on exercise
Complete the capstone and ask another person to reproduce it from an empty database.
Acceptance criterion: they can build, test, dump, restore, and explain the system using only submitted artifacts.
Knowledge check
- What is an automatic capstone failure?
- Why include overlapping tenant data?
- What is stronger than a screenshot?
Answers
- Any cross-tenant acceptance/leak.
- It exposes missing ownership keys and filters.
- Reproducible commands, fixtures, assertions, outputs, and restore validation.
Completion checklist
Primary references