SKILL.md
508 lines · 2,214 words
Database Architect
Purpose
Design database schemas that balance data integrity, query performance, and operational maintainability. This skill covers relational database design principles, indexing strategies, scaling patterns, and migration management for production systems.
Normalization
Normal Forms
1NF (First Normal Form):
- Each column contains atomic (indivisible) values
- Each row is unique (has primary key)
- No repeating groups
VIOLATION: tags = "red,blue,green" (comma-separated)
FIX: Create a separate tags table with one row per tag
2NF (Second Normal Form):
- Meets 1NF
- No partial dependencies (all non-key columns depend on the FULL primary key)
- Only relevant with composite primary keys
VIOLATION: (order_id, product_id) -> product_name
product_name depends only on product_id, not the full key
FIX: Move product_name to the products table
3NF (Third Normal Form):
- Meets 2NF
- No transitive dependencies (non-key column depends on another non-key column)
VIOLATION: user_id -> department_id -> department_name
department_name depends on department_id, not directly on user_id
FIX: Create a departments table, reference via department_id
BCNF (Boyce-Codd Normal Form):
- Meets 3NF
- Every determinant is a candidate key
- Handles edge cases where 3NF allows anomalies
4NF (Fourth Normal Form):
- Meets BCNF
- No multi-valued dependencies
5NF (Fifth Normal Form):
- Meets 4NF
- No join dependencies
PRACTICAL TARGET: 3NF for OLTP, denormalized for OLAP/reporting.