Skills › Knowledge Work Plugins › data-context-extractor › domain-template.md
domain-template.md
147 lines · data/skills/data-context-extractor/references/domain-template.md at 2574e29
1# Domain Reference File Template
3Use this template when creating reference files for specific data domains (e.g., revenue, users, marketing).
5---
7```markdown
8# [DOMAIN_NAME] Tables
10This document contains [domain]-related tables, metrics, and query patterns.
12---
14## Quick Reference
16### Business Context
18[2-3 sentences explaining what this domain covers and key concepts]
20### Entity Clarification
22**"[AMBIGUOUS_TERM]" can mean:**
23- **[MEANING_1]**: [DEFINITION] ([TABLE]: [ID_FIELD])
24- **[MEANING_2]**: [DEFINITION] ([TABLE]: [ID_FIELD])
26Always clarify which one before querying.
28### Standard Filters
30For [domain] queries, always:
31```sql
32WHERE [STANDARD_FILTER_1]
33 AND [STANDARD_FILTER_2]
34```
36---
38## Key Tables
40### [TABLE_1_NAME]
41**Location**: `[project.dataset.table]` or `[schema.table]`
42**Description**: [What this table contains, when to use it]
43**Primary Key**: [COLUMN(S)]
44**Update Frequency**: [Daily/Hourly/Real-time] ([LAG] lag)
45**Partitioned By**: [PARTITION_COLUMN] (if applicable)
47| Column | Type | Description | Notes |
48|--------|------|-------------|-------|
49| **[column_1]** | [TYPE] | [DESCRIPTION] | [GOTCHA_OR_CONTEXT] |
50| **[column_2]** | [TYPE] | [DESCRIPTION] | |
51| **[column_3]** | [TYPE] | [DESCRIPTION] | Nullable |
53**Relationships**:
54- Joins to `[OTHER_TABLE]` on `[JOIN_KEY]`
55- Parent of `[CHILD_TABLE]` via `[FOREIGN_KEY]`
57**Nested/Struct Fields** (if applicable):
58- `[struct_name].[field_1]`: [DESCRIPTION]
59- `[struct_name].[field_2]`: [DESCRIPTION]
61---
63### [TABLE_2_NAME]
64[REPEAT FORMAT]
66---
68## Key Metrics
70| Metric | Definition | Table | Formula | Notes |
71|--------|------------|-------|---------|-------|
72| [METRIC_1] | [DEFINITION] | [TABLE] | `[FORMULA]` | [CAVEATS] |
73| [METRIC_2] | [DEFINITION] | [TABLE] | `[FORMULA]` | |
75---
77## Sample Queries
79### [QUERY_PURPOSE_1]
80```sql
81-- [Brief description of what this query does]
82SELECT
83 [columns]
84FROM [table]
85WHERE [standard_filters]
86GROUP BY [grouping]
87ORDER BY [ordering]
88```
90### [QUERY_PURPOSE_2]
91```sql
92[ANOTHER_COMMON_QUERY]
93```
95### [QUERY_PURPOSE_3]: [More Complex Pattern]
96```sql
97WITH [cte_name] AS (
98 [CTE_LOGIC]
99)
100SELECT
101 [final_columns]
102FROM [cte_name]
103[joins_and_filters]
104```
106---
108## Common Gotchas
1101. **[GOTCHA_1]**: [EXPLANATION]
111 - Wrong: `[INCORRECT_APPROACH]`
112 - Right: `[CORRECT_APPROACH]`
1142. **[GOTCHA_2]**: [EXPLANATION]
116---
118## Related Dashboards (if applicable)
120| Dashboard | Link | Use For |
121|-----------|------|---------|
122| [DASHBOARD_1] | [URL] | [DESCRIPTION] |
123| [DASHBOARD_2] | [URL] | [DESCRIPTION] |
124```
126---
Domain Reference File Template
Use this template when creating reference files for specific data domains (e.g., revenue, users, marketing).
# [DOMAIN_NAME] Tables
This document contains [domain]-related tables, metrics, and query patterns.
---
## Quick Reference
### Business Context
[2-3 sentences explaining what this domain covers and key concepts]
### Entity Clarification
**"[AMBIGUOUS_TERM]" can mean:**
- **[MEANING_1]**: [DEFINITION] ([TABLE]: [ID_FIELD])
- **[MEANING_2]**: [DEFINITION] ([TABLE]: [ID_FIELD])
Always clarify which one before querying.
### Standard Filters
For [domain] queries, always:WHERE [STANDARD_FILTER_1] AND [STANDARD_FILTER_2]
---
## Key Tables
### [TABLE_1_NAME]
**Location**: `[project.dataset.table]` or `[schema.table]`
**Description**: [What this table contains, when to use it]
**Primary Key**: [COLUMN(S)]
**Update Frequency**: [Daily/Hourly/Real-time] ([LAG] lag)
**Partitioned By**: [PARTITION_COLUMN] (if applicable)
| Column | Type | Description | Notes |
|--------|------|-------------|-------|
| **[column_1]** | [TYPE] | [DESCRIPTION] | [GOTCHA_OR_CONTEXT] |
| **[column_2]** | [TYPE] | [DESCRIPTION] | |
| **[column_3]** | [TYPE] | [DESCRIPTION] | Nullable |
**Relationships**:
- Joins to `[OTHER_TABLE]` on `[JOIN_KEY]`
- Parent of `[CHILD_TABLE]` via `[FOREIGN_KEY]`
**Nested/Struct Fields** (if applicable):
- `[struct_name].[field_1]`: [DESCRIPTION]
- `[struct_name].[field_2]`: [DESCRIPTION]
---
### [TABLE_2_NAME]
[REPEAT FORMAT]
---
## Key Metrics
| Metric | Definition | Table | Formula | Notes |
|--------|------------|-------|---------|-------|
| [METRIC_1] | [DEFINITION] | [TABLE] | `[FORMULA]` | [CAVEATS] |
| [METRIC_2] | [DEFINITION] | [TABLE] | `[FORMULA]` | |
---
## Sample Queries
### [QUERY_PURPOSE_1]-- [Brief description of what this query does] SELECT [columns] FROM [table] WHERE [standard_filters] GROUP BY [grouping] ORDER BY [ordering]
### [QUERY_PURPOSE_2][ANOTHER_COMMON_QUERY]
### [QUERY_PURPOSE_3]: [More Complex Pattern]WITH [cte_name] AS ( [CTE_LOGIC] ) SELECT [final_columns] FROM [cte_name] [joins_and_filters]
---
## Common Gotchas
1. **[GOTCHA_1]**: [EXPLANATION]
- Wrong: `[INCORRECT_APPROACH]`
- Right: `[CORRECT_APPROACH]`
2. **[GOTCHA_2]**: [EXPLANATION]
---
## Related Dashboards (if applicable)
| Dashboard | Link | Use For |
|-----------|------|---------|
| [DASHBOARD_1] | [URL] | [DESCRIPTION] |
| [DASHBOARD_2] | [URL] | [DESCRIPTION] |Raw lines 1 to 127
128## Tips for Creating Domain Files
1301. **Start with the most-queried tables** - Don't try to document everything
1312. **Include column-level detail only for important columns** - Skip obvious ones like `created_at`
1323. **Real query examples > abstract descriptions** - Show don't tell
1334. **Document the gotchas prominently** - These save the most time
1345. **Keep sample queries runnable** - Use real table/column names
1356. **Note nested/struct fields explicitly** - These trip people up
Tips for Creating Domain Files
- Start with the most-queried tables - Don't try to document everything
- Include column-level detail only for important columns - Skip obvious ones like
created_at - Real query examples > abstract descriptions - Show don't tell
- Document the gotchas prominently - These save the most time
- Keep sample queries runnable - Use real table/column names
- Note nested/struct fields explicitly - These trip people up
137## Suggested Domain Files
139Common domains to document (create separate files for each):
141- `revenue.md` - Billing, subscriptions, ARR, transactions
142- `users.md` - Accounts, authentication, user attributes
143- `product.md` - Feature usage, events, sessions
144- `growth.md` - DAU/WAU/MAU, retention, activation
145- `sales.md` - CRM, pipeline, opportunities
146- `marketing.md` - Campaigns, attribution, leads
147- `support.md` - Tickets, CSAT, response times
Suggested Domain Files
Common domains to document (create separate files for each):
revenue.md- Billing, subscriptions, ARR, transactionsusers.md- Accounts, authentication, user attributesproduct.md- Feature usage, events, sessionsgrowth.md- DAU/WAU/MAU, retention, activationsales.md- CRM, pipeline, opportunitiesmarketing.md- Campaigns, attribution, leadssupport.md- Tickets, CSAT, response times