Data Model Layer Skill
Layer Number: 07
Specification: Metadata Model Spec v0.7.0
Purpose: Defines logical data structures using JSON Schema Draft 7, specifying entities, properties, validation rules, and data governance.
Layer Overview
The Data Model Layer captures logical data structures:
- SCHEMAS - Object, array, string, numeric schemas
- VALIDATION - Type constraints, required fields, patterns, ranges
- COMPOSITION - Schema combinations (allOf, anyOf, oneOf, not)
- GOVERNANCE - Data classification, PII, retention policies
- INTEGRATION - Links to business objects, database tables, API operations
This layer uses JSON Schema Draft 7 (industry standard) with custom extensions for cross-layer traceability.
Central Entity: The ObjectSchema (defining an object structure) is the core modeling unit.
Entity Types
Core JSON Schema Entities (17 entities)
| Entity Type |
Description |
| JSONSchema |
Root schema document |
| ObjectSchema |
Defines object structure with properties |
| ArraySchema |
Defines array with items and constraints |
| StringSchema |
String validation (length, pattern, format) |
| NumericSchema |
Number/integer validation (min, max, multipleOf) |
| SchemaComposition |
Combines schemas (allOf, anyOf, oneOf, not) |
| SchemaProperty |
Individual property definition |
| Reference |
$ref to other schemas |
| DataGovernance |
Governance annotations (classification, retention) |
| DatabaseMapping |
Maps to physical database (x-database extension) |
When to Use This Skill
Activate when the user:
- Mentions "data model", "schema", "JSON Schema", "data structure"
- Wants to define object structures, properties, or validation rules
- Asks about data types, constraints, or data governance
- Needs to model entities like User, Order, Product, etc.
- Wants to link data models to APIs or databases
Cross-Layer Relationships
Outgoing (Data Model → Other Layers):
x-business-object-ref → Business Layer (what business concept does this represent?)
x-database → Datastore Layer (how is this stored physically?)
x-data-governance → Security Layer (classification, PII, retention)
x-apm-data-quality-metrics → APM Layer (data quality monitoring)
Incoming (Other Layers → Data Model):
- API Layer → Data Model (request/response schemas via $ref)
- UX Layer → Data Model (form validation rules)
- Testing Layer → Data Model (input constraints for test partitioning)
Validation Best Practices
- Required fields - Use
required array for mandatory properties
- Type validation - Always specify
type (object, array, string, number, etc.)
- Format validation - Use
format for email, uuid, date-time, uri, etc.
- Range validation - Use min/max for numbers, minLength/maxLength for strings
- Pattern validation - Use
pattern for regex validation (e.g., phone numbers)
- Data governance - Always add
x-data-governance for sensitive data
- Reusability - Use
$ref to reference shared schemas
Common Commands
# Add object schema
dr add data_model object-schema --name "User" --property type=object
# List data models
dr list data_model object-schema
# Validate data model layer
dr validate --layer data_model
# Export as JSON Schema
dr export --layer data_model --format json-schema
Example: User Schema
id: data_model.object-schema.user
name: "User Schema"
type: object-schema
properties:
type: object
required: [id, email, username]
properties:
id:
type: string
format: uuid
description: "Unique user identifier"
email:
type: string
format: email
description: "User email address"
x-data-governance:
classification: confidential
pii: true
username:
type: string
minLength: 3
maxLength: 50
pattern: "^[a-zA-Z0-9_-]+$"
created_at:
type: string
format: date-time
roles:
type: array
items:
type: string
description: "User role assignments"
x-business-object-ref: business.actor.user
x-database:
table: users
schema: public
Pitfalls to Avoid
- ❌ Missing
type field (validation will fail)
- ❌ Not marking PII/sensitive data with governance
- ❌ Overly complex schemas (break into smaller reusable schemas)
- ❌ Not using
$ref for shared definitions
- ❌ Missing cross-layer links to business and database layers
1---2name: layer-07-data-model3description: Expert knowledge for Data Model Layer modeling in Documentation Robotics4---5
6# Data Model Layer Skill
7
8**Layer Number:** 07
9**Specification:** Metadata Model Spec v0.7.0
10**Purpose:** Defines logical data structures using JSON Schema Draft 7, specifying entities, properties, validation rules, and data governance.
11
12---
13
14## Layer Overview
15
16The Data Model Layer captures **logical data structures**:
17
18- **SCHEMAS** - Object, array, string, numeric schemas
19- **VALIDATION** - Type constraints, required fields, patterns, ranges
20- **COMPOSITION** - Schema combinations (allOf, anyOf, oneOf, not)
21- **GOVERNANCE** - Data classification, PII, retention policies
22- **INTEGRATION** - Links to business objects, database tables, API operations
23
24This layer uses **JSON Schema Draft 7** (industry standard) with custom extensions for cross-layer traceability.
25
26**Central Entity:** The **ObjectSchema** (defining an object structure) is the core modeling unit.
27
28---
29
30## Entity Types
31
32### Core JSON Schema Entities (17 entities)
33
34| Entity Type | Description |
35| --------------------- | -------------------------------------------------- |
36| **JSONSchema** | Root schema document |
37| **ObjectSchema** | Defines object structure with properties |
38| **ArraySchema** | Defines array with items and constraints |
39| **StringSchema** | String validation (length, pattern, format) |
40| **NumericSchema** | Number/integer validation (min, max, multipleOf) |
41| **SchemaComposition** | Combines schemas (allOf, anyOf, oneOf, not) |
42| **SchemaProperty** | Individual property definition |
43| **Reference** | $ref to other schemas |
44| **DataGovernance** | Governance annotations (classification, retention) |
45| **DatabaseMapping** | Maps to physical database (x-database extension) |
46
47---
48
49## When to Use This Skill
50
51Activate when the user:
52
53- Mentions "data model", "schema", "JSON Schema", "data structure"
54- Wants to define object structures, properties, or validation rules
55- Asks about data types, constraints, or data governance
56- Needs to model entities like User, Order, Product, etc.
57- Wants to link data models to APIs or databases
58
59---
60
61## Cross-Layer Relationships
62
63**Outgoing (Data Model → Other Layers):**
64
65- `x-business-object-ref` → Business Layer (what business concept does this represent?)
66- `x-database` → Datastore Layer (how is this stored physically?)
67- `x-data-governance` → Security Layer (classification, PII, retention)
68- `x-apm-data-quality-metrics` → APM Layer (data quality monitoring)
69
70**Incoming (Other Layers → Data Model):**
71
72- API Layer → Data Model (request/response schemas via $ref)
73- UX Layer → Data Model (form validation rules)
74- Testing Layer → Data Model (input constraints for test partitioning)
75
76---
77
78## Validation Best Practices
79
801. **Required fields** - Use `required` array for mandatory properties
812. **Type validation** - Always specify `type` (object, array, string, number, etc.)
823. **Format validation** - Use `format` for email, uuid, date-time, uri, etc.
834. **Range validation** - Use min/max for numbers, minLength/maxLength for strings
845. **Pattern validation** - Use `pattern` for regex validation (e.g., phone numbers)
856. **Data governance** - Always add `x-data-governance` for sensitive data
867. **Reusability** - Use `$ref` to reference shared schemas
87
88---
89
90## Common Commands
91
92```bash
93# Add object schema
94dr add data_model object-schema --name "User" --property type=object
95
96# List data models
97dr list data_model object-schema
98
99# Validate data model layer
100dr validate --layer data_model
101
102# Export as JSON Schema
103dr export --layer data_model --format json-schema
104```
105
106---
107
108## Example: User Schema
109
110```yaml
111id: data_model.object-schema.user
112name: "User Schema"
113type: object-schema
114properties:
115 type: object
116 required: [id, email, username]
117 properties:
118 id:
119 type: string
120 format: uuid
121 description: "Unique user identifier"
122 email:
123 type: string
124 format: email
125 description: "User email address"
126 x-data-governance:
127 classification: confidential
128 pii: true
129 username:
130 type: string
131 minLength: 3
132 maxLength: 50
133 pattern: "^[a-zA-Z0-9_-]+$"
134 created_at:
135 type: string
136 format: date-time
137 roles:
138 type: array
139 items:
140 type: string
141 description: "User role assignments"
142 x-business-object-ref: business.actor.user
143 x-database:
144 table: users
145 schema: public
146```
147
148---
149
150## Pitfalls to Avoid
151
152- ❌ Missing `type` field (validation will fail)
153- ❌ Not marking PII/sensitive data with governance
154- ❌ Overly complex schemas (break into smaller reusable schemas)
155- ❌ Not using `$ref` for shared definitions
156- ❌ Missing cross-layer links to business and database layers