Chapter 18 · Capstone: Design and Query a Complete Database

Capstone Requirements and Conceptual Model

A successful database begins before CREATE TABLE. In this capstone you will convert an intentionally imperfect business brief into explicit scope, durable business rules, entity identities, relationship cardinalities, history requirements, and measurable acceptance criteria.

Capstone175–215 minutesRequirements analysis + conceptual modeling workshopLast reviewed: August 2026

Learning outcomes

Learning outcomes

01

Convert an ambiguous business brief into an explicit problem statement, scope, actors, use cases, and non-functional requirements.

02

Define the grain, identity, lifecycle, and history policy for every major entity.

03

Derive cardinalities and optionality from business rules instead of drawing relationships by intuition.

04

Separate conceptual requirements from logical tables and product-specific implementation details.

05

Write measurable acceptance criteria that later schema, query, transaction, security, and recovery tests can prove.

Capstone scenario: Northstar Supply

Northstar Supply is a small business-to-business commerce company that sells technical books, office equipment, and computing accessories. Customers place orders through an application, choose a saved shipping address, and receive products from one of several warehouses. Operations staff need accurate stock, payment, shipment, and audit information. Management needs monthly revenue, product performance, customer value, and inventory-risk reports.

CUS

Customer service

Find a customer, inspect an order, explain its status, and confirm the shipping destination without exposing unrelated customer data.

FUL

Fulfillment

See submitted or paid orders, reserve available inventory, create shipments, and avoid allocating the same stock twice.

FIN

Finance

Reconcile captured and refunded payments with order totals and investigate exceptions.

ANA

Analytics

Measure recognized revenue, product demand, regional performance, repeat purchasing, and stock risk from reproducible queries.

Business brief
Clarified requirements
Conceptual entities
Business rules
Acceptance criteria
Logical schema

Do not jump directly from prose to tables. Each transition should leave reviewable evidence.

Scope and boundary decisions

AreaIn scope for version 1Explicitly out of scope
CustomersAccount identity, status, region, reusable shipping addressesAuthentication credentials, marketing consent center, customer-support tickets
CatalogCategory hierarchy, SKU, product name, current price, active stateVariants, bundles, supplier procurement, multi-currency price lists
InventoryOn-hand, reserved, reorder point per warehouse and productLot tracking, serial numbers, damaged stock, inter-warehouse transfers
OrdersOrder header, immutable line-price snapshots, status, idempotency keyDiscount engine, tax calculation, returns authorization
PaymentsProvider reference, amount, lifecycle state, paid timestampCard data, settlement batches, chargeback workflow
ShipmentsOne warehouse per shipment, tracking, lifecycle timestampsCarrier rate shopping, multi-package detail, shipment-line allocation
OperationsAudit events, backup and restore procedure, query-plan evidenceHigh availability, cross-region replication, full observability platform

Actors and prioritized use cases

text · requirements catalogue
ACTOR customer-service  UC-01 Search customer by email.  UC-02 Show order header, lines, totals, payment, and shipment.ACTOR fulfillment-worker  UC-03 List orders ready for fulfillment in deterministic priority order.  UC-04 Reserve stock atomically and create a shipment.ACTOR finance-analyst  UC-05 Reconcile captured/refunded payments against order totals.ACTOR business-analyst  UC-06 Report monthly recognized revenue by region.  UC-07 Rank products and customers by net revenue.ACTOR platform-engineer  UC-08 Restore a verified backup within the recovery objective.  UC-09 Prove least-privilege access and query-plan expectations.

Conceptual entities and grain

EntityOne row representsStable identityImportant lifecycle
CustomerOne commercial customer accountcustomer_id; email is an alternate keyactive → suspended/closed
AddressOne named address saved by one customeraddress_id; customer + label uniqueeditable until used; later changes create a new address row so order history remains stable
CategoryOne catalog classification nodecategory_id; category_code alternate keyoptional parent creates a hierarchy
ProductOne sellable SKUproduct_id; sku alternate keyactive/inactive without deleting history
InventoryOne product balance at one warehousewarehouse_id + product_idon_hand and reserved change transactionally
Sales orderOne checkout requestorder_id; order_number and request_key alternate keysdraft → submitted/paid/packed/shipped or cancelled
Order itemOne product line within one orderorder_id + line_noprice is a snapshot, not a lookup of today’s price
PaymentOne provider-side payment attempt/resultpayment_id; provider_ref alternate keyauthorized/captured/failed/refunded
ShipmentOne fulfillment movement from one warehouseshipment_id; tracking code optional alternate keypending/packed/shipped/delivered/returned
Audit eventOne append-only record of a meaningful actionevent_idnever updated as business state

Relationships, cardinality, and optionality

Customer 1
Address 0..*
Sales order 0..*
Order item 1..*
Product 1
Inventory 0..*
Warehouse 1

The diagram is a reading path, not a substitute for precise relationship rules.

RelationshipCardinalityReasoning test
Customer → Addressone-to-many; address requires a customerCan a customer have two saved addresses? Yes. Can an address exist without an owner? No.
Customer → Sales orderone-to-many; order requires a customerHistorical orders survive customer suspension; the account is not physically deleted.
Sales order → Order itemone-to-many; submitted orders require at least one lineThe database enforces line ownership; service logic verifies the at-least-one rule at submission.
Product ↔ Warehousemany-to-many resolved by InventoryBalances have relationship attributes: on_hand, reserved, reorder_point, updated_at.
Sales order → Paymentone-to-many in the modelRetries, failures, and refunds may create multiple payment records over time.
Sales order → Shipmentone-to-many in the modelVersion 1 seed data uses one shipment, but the model does not prevent future split shipments.
Category → Categoryoptional recursive parentA root category has no parent; a child has one parent.

Business rules as testable invariants

text · invariant register
BR-01 customer.email is case-insensitively unique.BR-02 each customer has at most one default address; an order address belongs to that customer.BR-03 inventory.reserved is never negative and never exceeds on_hand.BR-04 order_item.quantity is positive; price is a nonnegative snapshot.BR-05 order_item.line_total = quantity × unit_price.BR-06 a request_key creates at most one sales order.BR-07 cancelled orders do not count as recognized revenue.BR-08 delivered_at may exist only when shipped_at exists.BR-09 inactive products remain queryable for historical orders.BR-10 payment provider references are globally unique.BR-11 destructive operations require explicit retention or archival policy.

Classify each rule by enforcement location: key, foreign key, CHECK, generated column, transaction, trigger, application service, scheduled reconciliation, or operating procedure. A rule is incomplete until its enforcement and test are named.

History, derived values, and ownership

QuestionDecisionWhy
Which price belongs on an old order?Store unit_price_cents on order_itemCurrent catalog price may change; the order line is historical evidence.
Should order total be stored?Derive from lines in reports; verify payment against the derived totalAvoid two independently mutable sources of truth in this course scope.
Can customers be deleted?Prefer status=closed; cascade addresses only in controlled test dataOrders and financial records need durable ownership history.
Who owns stock reservation?One transactional order-placement serviceA single invariant owner reduces race conditions and inconsistent retries.
Where is recognized revenue defined?Captured payments for non-cancelled ordersThe metric definition becomes query and documentation, not tribal knowledge.

Non-functional requirements

QualityAcceptance target
CorrectnessForeign keys enabled; integrity checks pass; transaction tests prove no partial order or over-reservation.
PerformanceNamed operational queries use intended indexes on representative data; plans are recorded.
SecurityApplication code binds values; read-only and write roles are separated in the production design.
RecoverabilityA backup is restored into a separate database and verified with integrity and row-count checks.
AuditabilityMeaningful order and inventory changes carry actor, timestamp, entity, action, and details.
MaintainabilitySchema, seed, queries, tests, migration notes, data dictionary, and runbook are version controlled.

Acceptance criteria and repository contract

text · final deliverable tree
northstar-capstone/  README.md  db/    001_schema.sql    002_seed.sql    003_indexes.sql    004_views.sql    queries/      operational.sql      analytical.sql      verification.sql    tests/      test_database.py    runbooks/      backup_restore.md      release_checklist.md    docs/      conceptual-model.md      data-dictionary.md      decisions/        001-price-snapshot.md        002-inventory-reservation.md  presentation/    capstone-outline.md

Requirements review

  1. Why is order-item price a snapshot rather than a foreign lookup of current product price?
  2. Why does the Inventory relationship need its own entity?
  3. Which “at least one order line” rule is difficult to express with a simple row-level constraint?
  4. What makes an acceptance criterion stronger than a design intention?
Review the answers

Historical prices must remain stable. Inventory has relationship attributes and a composite identity. Row constraints cannot normally inspect the complete child set at order-submission time, so a transaction or deferred workflow must validate it. Acceptance criteria name observable evidence, expected outcomes, and failure behavior.

Lesson summary

  • Requirements define scope, actors, decisions, quality targets, and exclusions before tables.
  • Every entity needs an explicit grain, stable identity, lifecycle, and history policy.
  • Cardinality follows business questions, not diagram aesthetics.
  • Business rules should be assigned to an enforcement mechanism and a test.
  • The capstone repository is an engineering product, not only a SQL script.

References

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only assets compatible with the Ethereum/ERC-20 network. Do not send TRC-20/TRON assets.