schema-design
Migration-ready database schema design with normalization and indexing strategies
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Migration-ready database schema design with normalization and indexing strategies
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | Schema Design |
| department | architect |
| description | Migration-ready database schema design with normalization and indexing strategies |
| version | 1 |
| triggers | ["database","schema","data model","table","migration","entity","relationship","foreign key","index","normalization"] |
Design relational database schemas with normalization trade-offs, migration plans, and indexing strategies. Produces migration-ready SQL that can be applied directly to the database.
Read current schema files, migration history, or ORM models. List all existing tables with their columns, types, constraints, and relationships. Note any existing indexes and RLS policies.
From the feature requirements and interview output, determine what new data needs to be stored. List candidate entities and their purpose.
For each new entity, define:
Define all relationships between entities:
Default to 3NF. For each denormalization decision, document:
Drive index choices from query patterns:
If using Supabase or row-level security:
Write executable SQL:
# Schema Design: [Feature Name]
## Entity Overview
| Entity | Purpose | New/Modified |
|--------|---------|-------------|
| ... | ... | ... |
## Entity Definitions
### [entity_name]
| Column | Type | Nullable | Default | Constraints |
|--------|------|----------|---------|-------------|
| id | uuid | NO | gen_random_uuid() | PK |
| ... | ... | ... | ... | ... |
## Relationships
[ASCII diagram] users 1──N posts posts N──M tags (through: post_tags)
## Index Strategy
| Table | Index | Columns | Type | Rationale |
|-------|-------|---------|------|-----------|
| ... | ... | ... | ... | ... |
## Denormalization Decisions
| What | Why | Consistency Strategy |
|------|-----|---------------------|
| ... | ... | ... |
## RLS Policies
| Table | Operation | Policy | Using |
|-------|-----------|--------|-------|
| ... | ... | ... | ... |
## Migration SQL
### Up
```sql
-- New tables
CREATE TABLE ...
-- Indexes
CREATE INDEX ...
-- RLS
ALTER TABLE ... ENABLE ROW LEVEL SECURITY;
CREATE POLICY ...
DROP POLICY ...
DROP INDEX ...
DROP TABLE ...
## Quality Checks
- [ ] Every entity has a primary key
- [ ] Foreign keys reference existing or newly created tables
- [ ] Indexes support the identified query patterns
- [ ] Migration is reversible (Down section undoes Up completely)
- [ ] RLS policies cover all access patterns (SELECT, INSERT, UPDATE, DELETE)
- [ ] Timestamp columns (created_at, updated_at) are present on mutable entities
- [ ] CASCADE behavior is explicitly defined for all foreign keys
- [ ] No orphan tables (every table is reachable via relationships or has a documented reason for isolation)
## Evolution Notes
<!-- Observations appended after each use -->
Fast codebase searches using grep/glob. Triggers on "find", "search", "where is", "grep for".
Use when working with dbt (data build tool) - creating models, writing tests, CI/CD pipelines, materializations, sources, staging/intermediate/marts layers, Snowflake/BigQuery warehouse configuration, incremental strategies, Jinja macros, data quality, semantic layer, or making analytics engineering decisions
Local git operations for syncing, branching, merging, and conflict resolution
GitHub interactions for issues, PRs, releases, and repository management
Interactive wizard to craft effective prompts using Claude Code best practices
Test-driven development reference for writing good tests, designing testable interfaces, mocking at system boundaries, and refactoring after green. Use when writing tests, reviewing test quality, or applying red-green-refactor workflow. Not for running test suites or CI configuration — use language-conventions or cicd-generation for those.