schema-design

Designs and reviews database schemas with constraints, keys, types, and normalization rules.

15|3|Updated Jul 9, 2026
One-click install
npx skills add https://github.com/kiurakku/cursor-kit-for-ai --skill schema-design-kiurakku
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: schema-design
Source: https://github.com/kiurakku/cursor-kit-for-ai/tree/main/plugins/data/skills/schema-design
Command: npx skills add https://github.com/kiurakku/cursor-kit-for-ai --skill schema-design-kiurakku

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database schemas designed without constraints, proper keys, or correct data types accumulate integrity problems that surface only after the application scales or gains a second writer. This Skill guides the modeling of entities, relationships, and constraints so the database itself enforces correctness instead of relying on application code. ## Core Features & Use Cases - Schema Design Process: Walks through entity listing, cardinality modeling (1:1, 1:N, M:N with junction tables), and 3NF normalization with measured denormalization guidance. - Key, Type, and Constraint Rules: Covers surrogate vs natural keys, NUMERIC money handling, timestamptz usage, CHECK constraints, FK ON DELETE behavior, partial unique indexes, and JSONB vs column trade-offs. - Review Checklist and Output Format: Audits existing schemas for missing PKs/FKs, float money, orphan rows, and fan-out traps, then delivers a mermaid ER diagram, DDL, and risk analysis. - Use Case: When modeling a new orders domain, use this Skill to produce DDL with identity primary keys, status CHECK constraints, idempotency unique keys, and RESTRICT delete behavior before writing any application code. ## Quick Start Ask the AI to design a Postgres schema for your domain entities with constraints, keys, and a mermaid ER diagram using the schema-design skill.

Frequently Asked Questions about schema-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a database schema for a new application?▼

Start by listing entities and the queries the app will run, then model relationships with real cardinality using foreign keys and junction tables. Normalize to 3NF by default and write DDL with constraints first, indexes second.

When should I use JSONB vs columns in Postgres?▼

Use JSONB for genuinely heterogeneous payloads like webhook bodies or user-defined fields. Use columns for anything queried, filtered, joined, or validated; if you write WHERE data->>'x' more than once, that field should be a column.

What data type should I use for money in SQL?▼

Use NUMERIC(precision, scale) or integer minor units for money, never float, because floating point introduces rounding errors. Add a CHECK constraint such as CHECK (total >= 0) to enforce validity at the database level.

Should I use UUID or bigint for primary keys?▼

Use BIGINT GENERATED ALWAYS AS IDENTITY for internal surrogate keys, or UUIDv7 when IDs are exposed or distributed since v4 fragments indexes. Natural keys like email get UNIQUE constraints but should not serve as primary keys.

How do I handle soft deletes without breaking unique constraints?▼

Add a deleted_at timestamptz column and use a partial unique index such as UNIQUE (email) WHERE deleted_at IS NULL. Every query must then filter soft-deleted rows via a view or ORM default scope.

When should foreign keys use ON DELETE CASCADE vs RESTRICT?▼

Default to RESTRICT so parent rows cannot be deleted while children exist. Use CASCADE only when child data is truly meaningless without the parent, and SET NULL for audit rows that should be preserved.