/sdlc-documentation:04-database-designfrom sdlc-documentation
Designs entity models, normalized schemas, keys, constraints, indexes, tenancy, retention, and migration plans from approved requirements and access patterns.
Ships in sdlc-documentation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Artefact | Source or provider | Required? | Missing behaviour |
|---|---|---|---|
| Approved entity rules and access patterns | SRS, HLD and API contracts | Required | Stop if ownership, lifecycle or identifiers are unresolved. |
| Workload, tenancy, retention and migration constraints | Operations, security and data owners | Required | Qualify absent volume evidence and avoid speculative indexes. |
| Artefact | Consumer | Observable acceptance condition |
|---|---|---|
| Database Design, entity model, data dictionary and migration plan | Backend, data, test, security and operations teams | Constraints enforce invariants; indexes map to named access patterns; migration has rollback and verification; sensitive data has retention and access rules. |
| Evidence | Consumer | Acceptance condition |
|---|---|---|
| Source and decision trace | Reviewer and downstream owner | Each material statement cites an approved input, named decision or qualified open issue. |
| Completed verification record | Release or phase gate owner | Every applicable check records pass/fail; unavailable checks remain not assessed. |
Read-only is the default for analysis, review, evaluation and planning. Read and search access to authorised project artefacts are required. Editing is limited to an explicitly requested project deliverable. Execution may run document, syntax or validation checks. Network access is used only for facts that require current verification. Do not publish, spend, change production, approve policy, or claim certification without explicit authority.
If any required capability is unavailable, return the narrowest useful qualified Database Design, entity model, data dictionary and migration plan draft plus a gap register showing the missing item, affected sections, risk and owner. Never convert an unassessed check into a pass.
| Choice | Action | Failure or risk avoided |
|---|---|---|
| Invariant must hold for every writer | Enforce with schema constraint where possible | Application bypass cannot corrupt data |
| Index has no named access pattern | Omit pending evidence | Write cost and storage are not wasted |
diagram-ir.schema.json, validated and generated.Produces comprehensive database design documentation including a visual Entity-Relationship Diagram (authored through diagram IR and rendered as Mermaid), normalized table definitions, indexing strategy, constraint specifications, migration plan, and a complete data dictionary. This skill can run after HLD is complete and may execute in parallel with API Specification (03-api-specification). When MySQL or MariaDB is selected, consult the engineering catalog's mysql-engineering skill and linked best-practices reference for applicable implementation patterns.
HLD.md exists in projects/<ProjectName>/<phase>/<document>/ and identifies data storage components.business_rules.md in projects/<ProjectName>/_context/ provides data relationships, validation rules, and constraints.tech_stack.md in projects/<ProjectName>/_context/ specifies the database platform.| Attribute | Value |
|---|---|
| Inputs | projects/<ProjectName>/<phase>/<document>/SRS_Draft.md, projects/<ProjectName>/<phase>/<document>/HLD.md, projects/<ProjectName>/_context/business_rules.md, projects/<ProjectName>/_context/tech_stack.md |
| Outputs | projects/<ProjectName>/<phase>/<document>/Database_Design.md, projects/<ProjectName>/<phase>/<document>/diagrams/erd.ir.json (Mermaid generated into _generated/) |
| Tone | Schema-precise, normalized, constraint-heavy |
| Standard | IEEE 1016-2009 Sec 6.7, ISO/IEC 25010 |
| File | Location | Required | Purpose |
|---|---|---|---|
| SRS_Draft.md | projects/<ProjectName>/<phase>/<document>/SRS_Draft.md | Yes | Entity candidates from Section 3.2, data objects from Section 2.0 |
| HLD.md | projects/<ProjectName>/<phase>/<document>/HLD.md | Yes | Data storage components, architectural context, data flow paths |
| business_rules.md | projects/<ProjectName>/_context/business_rules.md | Yes | Data relationships, validation constraints, business logic rules |
| tech_stack.md | projects/<ProjectName>/_context/tech_stack.md | Yes | Database platform (MySQL 8.x, PostgreSQL, etc.), version constraints |
| File | Location | Description |
|---|---|---|
| Database_Design.md | projects/<ProjectName>/<phase>/<document>/Database_Design.md | Complete database design document with all sections |
| erd.ir.json | projects/<ProjectName>/<phase>/<document>/diagrams/erd.ir.json | Diagram IR for the entity-relationship model; diagrams generate writes the Mermaid erDiagram to _generated/FIG-nnn.mmd |
Follow these eleven steps in order. Halt and notify the user if a required input file is missing.
Read SRS_Draft.md and HLD.md from projects/<ProjectName>/<phase>/<document>/, and business_rules.md and tech_stack.md from projects/<ProjectName>/_context/. Log the absolute path of each file read. If any required file is missing, halt execution and report the gap.
Parse tech_stack.md to identify the target database platform (MySQL, PostgreSQL, MariaDB, etc.). If the platform is MySQL or MariaDB, load the engineering catalog's mysql-engineering skill and its mysql-best-practices reference for applicable implementation patterns. Document the project-selected platform version and any engine-specific constraints; do not infer a version from this reference.
Extract entity candidates from SRS Section 3.2 (functional requirements) and Section 2.0 (data objects). Each entity becomes a table candidate. Cross-reference with business_rules.md to identify additional entities implied by relationships or constraints. List all identified entities with a one-sentence description.
Author an erd IR figure at projects/<ProjectName>/<phase>/<document>/diagrams/erd.ir.json (see ../01-high-level-design/references/diagram-ir-authoring.md): one entity node per table with typed attributes (key pk, fk or none; DECIMAL(19,4) for money), one edge per relationship with cardinality (1:1, 1:N, N:M, 0..1:N), and a junction entity for every many-to-many relationship. Trace each entity to the FRs that create or read it. Run python -m engine diagrams validate and python -m engine diagrams generate; the generated _generated/FIG-nnn.mmd replaces the hand-written erd.mmd, and <!-- diagram-ir: FIG-nnn --> embeds the figure in Database_Design.md.
Analyze every table against normalization forms:
Document any intentional denormalization with a performance rationale citing specific query patterns or SRS requirements that justify the deviation.
For each table, specify: column name, data type, nullable flag, default value, and constraints (PK, FK, UNIQUE, CHECK, NOT NULL). Monetary values SHALL use DECIMAL(19,4) per the logic-modeling convention. Every table SHALL include id (PK), created_at, and updated_at audit columns. Include deleted_at for soft-delete tables where business rules require data retention.
For every foreign key, explicitly state: parent table, child table, column mapping, ON DELETE action (CASCADE, SET NULL, RESTRICT), and ON UPDATE action. Referential integrity SHALL be enforced at the database level. Foreign key columns SHALL be indexed.
Define indexes for each table with rationale:
Produce a comprehensive data dictionary covering every field across all tables:
| Table | Field | Type | Description | Constraints | Example Value |
|---|
Every column in every table SHALL appear in this dictionary.
Document the migration approach: versioned migrations (up/down scripts), seed data for reference tables, rollback procedures for each migration, and environment-specific considerations (dev, staging, production).
If multi-tenancy is detected in SRS or HLD, define the tenant isolation strategy: shared database with tenant_id FK on every tenant-scoped table, or separate schemas. The tenant_id column SHALL have a foreign key constraint and be included in composite indexes for query performance. Where the system issues document numbers, specify the counter table keyed on (tenant, document type), a nullable number column while draft, a unique key on (tenant, number) per numbered table, a durable idempotency-key column, the column widths and the numbering audit table from the document numbering standard (sections 7 and 8). Write Database_Design.md and diagrams/erd.ir.json to projects/<ProjectName>/<phase>/<document>/, then validate and generate. Log total table count, column count, and relationship count.
The generated Database_Design.md shall use this section structure with a Document Header (Date, Version, Authors, Standard, Database Platform), followed by nine sections:
<!-- diagram-ir: FIG-nnn --> marker for the ERD IR (typed attributes and cardinality)Example ERD IR (generated into Mermaid erDiagram by python -m engine diagrams generate):
{
"schema_version": 1,
"diagram_kind": "erd",
"meta": {"figure_id": "FIG-001", "title": "Order data model", "caption": "Users, orders and order items",
"alt_text": "Entity-relationship diagram: a user places many orders; each order contains one or more order items.",
"srs_section": "3.3", "owner_document": "03-design-documentation/04-database-design/Database_Design.md"},
"nodes": [
{"id": "users", "label": "Users", "role": "entity", "trace": ["FR-001"],
"attributes": [{"name": "id", "type": "INT", "key": "pk"}, {"name": "email", "type": "VARCHAR(255)", "key": "none"}]},
{"id": "orders", "label": "Orders", "role": "entity", "trace": ["FR-002"],
"attributes": [{"name": "id", "type": "INT", "key": "pk"}, {"name": "user_id", "type": "INT", "key": "fk"},
{"name": "total_amount", "type": "DECIMAL(19,4)", "key": "none"}]}
],
"edges": [{"id": "places", "from": "users", "to": "orders", "label": "places", "cardinality": "1:N"}],
"evidence": {"srs_section": "3.3", "source_documents": ["02-requirements-engineering/01-srs/srs.md"]}
}
| Pitfall | Remedy |
|---|---|
| Missing indexes on foreign keys | Every FK column SHALL have a corresponding index |
| No cascade rules defined | Every FK SHALL specify ON DELETE and ON UPDATE actions |
| Monetary values not using DECIMAL(19,4) | All currency/monetary columns SHALL use DECIMAL(19,4) |
| Missing soft delete columns | Tables with data retention rules SHALL include deleted_at |
| No audit columns | Every table SHALL have created_at and updated_at columns |
| Denormalization without rationale | Document the performance justification for every deviation from 3NF |
Database_Design.md and diagrams/erd.ir.json exist in projects/<ProjectName>/<phase>/<document>/.python -m engine diagrams validate with no HIGH finding, and the generated erDiagram renders through scripts/build-doc.sh.DECIMAL(19,4).mysql-engineering skill and linked best-practices reference reviewed if MySQL or MariaDB is the selected platform.| Direction | Skill | Relationship |
|---|---|---|
| Upstream | 01-high-level-design | Consumes HLD.md for data storage components and data flow paths |
| Downstream | Phase 04 (Development) | Provides schema definitions for ORM models and migration scripts |
| Downstream | Phase 05 (Testing) | Provides table structure for data integrity and constraint test cases |
| Reference | mysql-engineering best-practices reference | Consult when MySQL or MariaDB is the selected platform |
logic.prompt -- Executable prompt containing the step-by-step database design generation logic.README.md -- Quick-start guide for this skill.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub peterbamuhigire/chwezi-sdlc-documentation --plugin sdlc-documentation160 skills in this plugin
/01-deployment-guideUse when producing or updating deployment guide for release prerequisites, migration choreography, verification, rollback, and ownership. Use runbook for the neighbouring concern; this skill owns the named document contract and its acceptance evidence./01-high-level-designUse when approved requirements need a system-level architecture with boundaries, components, critical flows, deployment topology and ADRs, or an as-built design must be recovered from existing code; use system-overview for orientation, low-level-design for module internals, and infrastructure-design for infrastructure depth./01-initialize-srsUse when writing a new SRS (software requirements specification) for a business system or module: create the Waterfall SRS workspace, IEEE structure, identifiers and source context; use context-engineering next for boundaries and actors./01-prd-generationUse when converting approved discovery evidence into a traceable PRD with objectives, prioritised features, success measures, constraints, and release scope; use vision-statement for the strategic north star and lean-canvas while assumptions still need testing./01-sprint-planningUse when preparing a sprint goal, evidence-based team capacity, selected backlog, task breakdown, and delivery risks. Use definition-of-ready to admit individual items and definition-of-done to judge completed increments./01-stakeholder-analysisUse when identifying and classifying stakeholders, influence, interests, decision rights, and communication needs before elicitation; use elicitation-toolkit to gather requirements from them.Other plugins' skills for the same job