Vander Labs

Skills / Code

Database schema design

Tables that make bad data impossible

Your AI designs or reviews a relational schema the way a database engineer on call would: entities and keys, types and constraints that enforce meaning, tenancy and soft-delete decisions, indexes derived from your real queries, and runnable migration SQL.

By Vander Labs. A Vander Labs Original, written by the Vander Labs team with AI assistance. Works with Claude, ChatGPT, Cursor and Claude Code.

What your AI learns

  • Models business facts, normalizes to 3NF and denormalizes only on purpose
  • Chooses keys, types and constraints that encode the rules
  • Indexes from the actual queries and writes expand-migrate-contract migrations

How it works

  1. Model entities: Entities with definitions and natural identifiers, relationships with cardinality, a Mermaid ERD.
  2. Normalize deliberately: Third normal form, then denormalization only for a measured read path with an invalidation rule.
  3. Choose keys: Identity or UUID surrogates, natural keys as unique constraints, foreign keys with explicit delete behavior.
  4. Pick types: timestamptz, numeric for money, text with checks, lookup tables over enums, jsonb only for schemaless data.
  5. Constraints: Not null by default, checks for ranges and states, unique and exclusion constraints for business rules.
  6. Standard patterns: Timestamps, tenant_id first in indexes with row-level security, partial unique indexes under soft delete.
  7. Index from queries: Composite indexes in equality, range, sort order per listed query, with explain analyze to confirm.
  8. Write the migration: Ordered SQL files, concurrent index creation, destructive changes split so old code keeps running.
  9. Review mode: Existing schemas checked against the same rules with severity and fix SQL.

Limits and safety

  • Says when a document store or a warehouse schema fits better than a relational design.
  • Refuses float for money and timestamp without time zone, and explains why.

Topics: postgresql, schema, sql, migrations, indexing