database-schema-design

supercent-io/skills-template · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/supercent-io/skills-template --skill database-schema-design
0 commentsdiscussion
summary

Design and optimize SQL and NoSQL database schemas with normalization, indexing, and migration strategies.

  • Covers entity definition, relationship design (1:1, 1:N, N:M), and normalization levels (1NF–3NF) for PostgreSQL, MySQL, MongoDB, and SQLite
  • Provides indexing strategies, constraint setup, and trigger implementation to ensure data integrity and query performance
  • Includes migration script generation with UP/DOWN rollback capabilities for safe schema evolution
  • Delivers complete
skill.md

Database Schema Design

When to use this skill

Lists specific situations where this skill should be triggered:

  • New Project: Database schema design for a new application
  • Schema Refactoring: Redesigning an existing schema for performance or scalability
  • Relationship Definition: Implementing 1:1, 1:N, N:M relationships between tables
  • Migration: Safely applying schema changes
  • Performance Issues: Index and schema optimization to resolve slow queries

Input Format

The required and optional input information to collect from the user:

Required Information

  • Database Type: PostgreSQL, MySQL, MongoDB, SQLite, etc.
  • Domain Description: What data will be stored (e.g., e-commerce, blog, social media)
  • Key Entities: Core data objects (e.g., User, Product, Order)

Optional Information

  • Expected Data Volume: Small (<10K rows), Medium (10K-1M), Large (>1M) (default: Medium)
  • Read/Write Ratio: Read-heavy, Write-heavy, Balanced (default: Balanced)
  • Transaction Requirements: Whether ACID is required (default: true)
  • Sharding/Partitioning: Whether large data distribution is needed (default: false)

Input Example

Design a database for an e-commerce platform:
- DB: PostgreSQL
- Entities: User, Product, Order, Review
- Relationships:
  - A User can have multiple Orders
  - An Order contains multiple Products (N:M)
  - A Review is linked to a User and a Product
- Expected data: 100,000 users, 10,000 products
- Read-heavy (frequent product lookups)

Instructions

Specifies the step-by-step task sequence to follow precisely.

Step 1: Define Entities and Attributes

Identify core data objects and their attributes.

Tasks:

  • Extract nouns from business requirements → entities
  • List each entity's attributes (columns)
  • Determine data types (VARCHAR, INTEGER, TIMESTAMP, JSON, etc.)
  • Designate Primary Keys (UUID vs Auto-increment ID)

Example (E-commerce):

Users
- id: UUID PRIMARY KEY
- email: VARCHAR(255) UNIQUE NOT NULL
- username: VARCHAR(50) UNIQUE NOT NULL
- password_hash: VARCHAR(255) NOT NULL
- created_at: TIMESTAMP DEFAULT NOW()
- updated_at: TIMESTAMP DEFAULT NOW()

Products
- id: UUID PRIMARY KEY
- name: VARCHAR(255) NOT NULL
- description: TEXT
- price: DECIMAL(10, 2) NOT NULL
- stock: INTEGER DEFAULT 0
- category_id: UUID REFERENCES Categories(id)
- created_at: TIMESTAMP DEFAULT NOW()

Orders
- id: UUID PRIMARY KEY
- user_id: UUID REFERENCES Users(id)
- total_amount: DECIMAL(10, 2) NOT NULL
- status: VARCHAR(20) DEFAULT 'pending'
- created_at: TIMESTAMP DEFAULT NOW()

OrderItems (Junction table)
- id: UUID PRIMARY KEY
- order_id: UUID REFERENCES Orders(id) ON DELETE CASCADE
- product_id: UUID REFERENCES Products(id)
- quantity: INTEGER NOT NULL
- price: DECIMAL(10, 2) NOT NULL

Step 2: Design Relationships and Normalization

Define relationships between tables and apply normalization.

Tasks:

  • 1:1 relationship: Foreign Key + UNIQUE constraint
  • 1:N relationship: Foreign Key
  • N:M relationship: Create junction table
  • Determine normalization level (1NF ~ 3NF)

Decision Criteria:

  • OLTP systems → normalize to 3NF (data integrity)
  • OLAP/analytics systems → denormalization allowed (query performance)
  • Read-heavy → minimize JOINs with partial denormalization
  • Write-heavy → full normalization to eliminate redundancy

Example (ERD Mermaid):

erDiagram
    Users ||--o{ Orders : places
    Orders ||--|{ OrderItems : contains
    Products ||--o{ OrderItems : "ordered in"
    Categories ||--o{ Products : categorizes
    Users ||--o{ Reviews : writes
    Products ||--o{ Reviews : "reviewed by"

    Users {
        uuid id PK
        string email UK
        string username UK
        string password_hash
        timestamp created_at
    }

    Products {
        uuid id PK
        string name
        decimal price
        int stock
        uuid category_id FK
    }

    Orders {
        uuid id PK
        uuid user_id FK
        decimal total_amount
        string status
        timestamp created_at
    }

    OrderItems {
        uuid id PK
        uuid order_id FK
        uuid product_id FK
        int quantity
        decimal price
    }

Step 3: Establish Indexing Strategy

Design indexes for query performance.

Tasks:

  • Primary Keys automatically create indexes
  • Columns frequently used in WHERE clauses → add indexes
  • Foreign Keys used in JOINs → indexes
  • Consider composite indexes (WHERE col1 = ? AND col2 = ?)
  • UNIQUE indexes (email, username, etc.)

Checklist:

  • Indexes on frequently queried columns
  • Indexes on Foreign Key columns
  • Composite index order optimized (high selectivity columns first)
  • Avoid excessive indexes (degrades INSERT/UPDATE performance)

Example (PostgreSQL):

-- Primary Keys (auto-indexed)
CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    email VARCHAR(255) UNIQUE NOT NULL,  -- UNIQUE = auto-indexed
    username VARCHAR(50) UNIQUE NOT NULL,
    password_hash VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT NOW(),
    updated_at TIMESTAMP DEFAULT NOW()
);

-- Foreign Keys + explicit indexes
CREATE TABLE orders (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    total_amount DECIMAL(10, 2) NOT NULL,
    status VARCHAR(20) DEFAULT 'pending',
    created_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX idx_orders_user_id ON orders(user_id);
CREATE INDEX idx_orders_status ON orders(status);
CREATE INDEX idx_orders_created_at ON orders(created_at);

-- Composite index (status and created_at frequently queried together)
CREATE INDEX idx_orders_status_created ON orders(status, created_at DESC);

-- Products table
CREATE TABLE products (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(255) NOT NULL,
    description TEXT,
    price DECIMAL(10, 2) NOT NULL CHECK (price >= 0),
    stock INTEGER DEFAULT 0 CHECK (stock >= 0),
    category_id UUID REFERENCES categories(id),
    created_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX idx_products_category ON products(category_id);
CREATE INDEX idx_products_price ON products(price);  -- price range search
CREATE INDEX idx_products_name ON products(name);    -- product name search

-- Full-text search (PostgreSQL)
CREATE INDEX idx_products_name_fts ON products USING GIN(to_tsvector('english', name));
CREATE INDEX idx_products_description_fts ON products USING GIN(to_tsvector('english', description));

Step 4: Set Up Constraints and Triggers

Add constraints to ensure data integrity.

Tasks:

  • NOT NULL: required columns
  • UNIQUE: columns that must be unique
  • CHECK: value range constraints (e.g., price >= 0)
  • Foreign Key + CASCADE option
  • Set default values

Example:

CREATE TABLE products (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(255) NOT NULL,
    price DECIMAL(10, 2) NOT NULL CHECK (price >= 0),
    stock INTEGER DEFAULT 0 CHECK (stock >= 0),
    discount_percent INTEGER CHECK (discount_percent >= 0 AND discount_percent <= 100),
    category_id UUID REFERENCES categories(id) ON DELETE SET NULL,
    created_at TIMESTAMP DEFAULT NOW(),
    updated_at TIMESTAMP DEFAULT NOW
how to use database-schema-design

How to use database-schema-design on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add database-schema-design
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/supercent-io/skills-template --skill database-schema-design

The skills CLI fetches database-schema-design from GitHub repository supercent-io/skills-template and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/database-schema-design

Reload or restart Cursor to activate database-schema-design. Access the skill through slash commands (e.g., /database-schema-design) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.671 reviews
  • Diya Iyer· Dec 24, 2024

    database-schema-design reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Diya Srinivasan· Dec 16, 2024

    We added database-schema-design from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Ira Gill· Dec 16, 2024

    Keeps context tight: database-schema-design is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Benjamin Kim· Dec 12, 2024

    Registry listing for database-schema-design matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Ira Sethi· Dec 8, 2024

    database-schema-design is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Pratham Ware· Dec 4, 2024

    database-schema-design reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ira Dixit· Nov 27, 2024

    Solid pick for teams standardizing on skills: database-schema-design is focused, and the summary matches what you get after install.

  • Yash Thakker· Nov 23, 2024

    I recommend database-schema-design for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Diya Robinson· Nov 15, 2024

    I recommend database-schema-design for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Kofi Mensah· Nov 11, 2024

    database-schema-design reduced setup friction for our internal harness; good balance of opinion and flexibility.

showing 1-10 of 71

1 / 8