Gate 5: Data structures document - defines entities, relationships, and ownership before database technology selection. Large Track only.
Runs before: ring:pre-dev-dependency-map Runs after: ring:pre-dev-api-design
Defines WHAT data exists, HOW entities relate, and WHO owns what data — before database technology selection.
If docs/pre-dev/{feature}/api-standards-ref.md exists, auto-detect naming convention.
If api-standards-ref.md EXISTS: AskUserQuestion: "How should database fields be named?"
If api-standards-ref.md DOES NOT EXIST: AskUserQuestion: "How should database fields be named?"
db-standards-ref.mdOption: Convert to snake_case — apply automatic rules:
Option: Keep same — copy field names without modification.
Option: Load from doc — WebFetch or read, extract field definitions, save to db-standards-ref.md.
| Phase | Activities |
|---|---|
| 1. Entity Identification | From API Design (Gate 4) and TRD (Gate 3): identify all entities; determine aggregate boundaries; map ownership per service |
| 2. Schema Definition | Per entity: define fields with types, constraints, indexes; apply naming strategy from Phase 0 |
| 3. Relationship Mapping | Define relationships (one-to-one, one-to-many, many-to-many); document foreign keys; specify cascade behavior |
| 4. Gate 5 Validation | All entities documented; relationships complete; ownership clear; field naming consistent; no tech-specific syntax |
### Entity: {EntityName}
**Ownership:** {service-name}
**Primary persistence:** Relational | Document | Key-value | Time-series
| Field | Type | Required | Constraints | Notes |
|-------|------|----------|-------------|-------|
| id | uuid | Yes | PK, unique | Auto-generated |
| name | string | Yes | max 255 chars | |
| status | enum | Yes | ACTIVE, INACTIVE, BLOCKED | |
| created_at | timestamp | Yes | UTC | |
| updated_at | timestamp | Yes | UTC | |
**Indexes:** [field combinations worth indexing for query patterns]
**Relationships:**
- has-many: {RelatedEntity} via {foreign_key}
- belongs-to: {ParentEntity} via {foreign_key}
CREATE TABLE)@Column, json:"field")| Structure | Files Generated |
|---|---|
| single-repo | docs/pre-dev/{feature}/data-model.md |
| monorepo | Root docs/pre-dev/{feature}/data-model.md |
| multi-repo | Both repos: {backend.path}/docs/pre-dev/{feature}/data-model.md + frontend copy |
| Category | Requirements |
|---|---|
| Entity Completeness | All API Design entities have data models; ownership clear; lifecycle states documented |
| Schema Quality | All required fields defined; types precise; constraints documented; naming consistent with db-standards-ref.md |
| Relationships | All entity relationships documented; cardinality correct; cascade rules specified |
| No Implementation | Zero SQL syntax; zero ORM annotations; zero database-specific types; zero migration scripts |
Gate Result: ✅ PASS → Dependency Map | ⚠️ CONDITIONAL (fix naming/missing entities) | ❌ FAIL (incomplete schema)