Works with the AI Agents you already use

    Database Design

    by Maulana Ruhaedi Putra

    1

    Design MySQL and PostgreSQL databases from scratch: planning process, ERD, 3NF normalization, data types, primary key, indexing, relationships, performance anti-patterns, transactions & migrations, security & backup.

    Free

    Security scanned
    Database Design

    Database Design

    Example session with this skill installed

    Design a PostgreSQL schema for a multi-tenant SaaS application where users can create projects and assign tasks. Include audit columns and handle soft deletes.

    • Read your context and instructions
    • Compiled the database design

    I have designed a normalized PostgreSQL schema for your multi-tenant SaaS. It uses UUIDv7 for public identifiers to prevent ID enumeration and includes TIMESTAMPTZ audit columns for all tables. Soft deletes are implemented with partial unique indexes to ensure app_user email uniqueness remains intact for active accounts.

    SaaS Project Management Schema

    -- Extension for UUID generation if not using application-side ULID/UUIDv7
    CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
    
    -- Tenants (Organizations)
    CREATE TABLE account (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        public_id UUID DEFAULT uuid_generate_v4() UNIQUE,
        name VARCHAR(255) NOT NULL,
        created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        deleted_at TIMESTAMPTZ
    );
    
    -- Users
    CREATE TABLE app_user (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        account_id BIGINT NOT NULL REFERENCES account(id) ON DELETE CASCADE,
        email VARCHAR(255) NOT NULL,
        full_name VARCHAR(255),
        created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        deleted_at TIMESTAMPTZ,
        CONSTRAINT fk_user_account FOREIGN KEY (account_id) REFERENCES account(id)
    );
    
    -- Partial index for soft delete email uniqueness
    CREATE UNIQUE INDEX uidx_user_email_active ON app_user (email) WHERE (deleted_at IS NULL);
    
    -- Projects
    CREATE TABLE project (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        account_id BIGINT NOT NULL REFERENCES account(id) ON DELETE CASCADE,
        owner_id BIGINT NOT NULL REFERENCES app_user(id),
        title VARCHAR(255) NOT NULL,
        description TEXT,
        created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        deleted_at TIMESTAMPTZ
    );
    
    -- Tasks
    CREATE TABLE task (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        project_id BIGINT NOT NULL REFERENCES project(id) ON DELETE CASCADE,
        assignee_id BIGINT REFERENCES app_user(id) ON DELETE SET NULL,
        subject VARCHAR(255) NOT NULL,
        body JSONB,
        status VARCHAR(50) DEFAULT 'todo',
        created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        deleted_at TIMESTAMPTZ
    );
    
    -- Indexes for Foreign Keys (PG requirement for performance)
    CREATE INDEX idx_user_account_id ON app_user(account_id);
    CREATE INDEX idx_project_account_id ON project(account_id);
    CREATE INDEX idx_task_project_id ON task(project_id);
    

    Next steps

    1. Review the task.body JSONB structure for specific metadata requirements.
    2. Implement Row Level Security (RLS) policies using the account_id as the tenant discriminator.
    3. Generate the V1 migration file and verify the execution plan for common tenant-wide queries.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Design MySQL and PostgreSQL databases from scratch: planning process, ERD, 3NF normalization, data types, primary key, indexing, relationships, performance anti-patterns, transactions & migrations, security & backup.

    Does not support MySQL 8.0 (EOL). SQL is validated via static analysis but requires live execution on PG 18/19 or MySQL 8.4 to verify runtime behavior.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 5 days ago

    • Free with an Agensi account

    Permissions

    Read Files
    Write Files
    Listed5 days ago

    What's inside

    Frequently Asked Questions

    This skill automates the creation of production-grade schemas, ensuring strict 3NF normalization, optimized indexing, and migration scripts that avoid common pitfalls like N+1 query issues or deadlock risks.

    It is optimized for PostgreSQL (versions 17-19) and MySQL (versions 8.4 and 9.7 LTS), generating DDL and migrations compatible with tools like Flyway, Liquibase, and DBML.

    Unlike generic prompts, this skill enforces platform-specific constraints such as PostgreSQL's 63-character identifier limits and mandates explicit foreign key actions (ON DELETE) and audit columns for every table.

    Yes, the skill includes a specific workflow for auditing existing schemas to identify anti-patterns, missing indexes, and performance bottlenecks, providing actionable refactoring paths.

    You receive the full agent skill logic designed for integration with your AI agent, including the specialized workflows for requirements mapping, relationship modeling, and security hardening.

    Due to the End-of-Life (EOL) status of MySQL 8.0, this skill exclusively targets modern LTS versions (8.4/9.7) to ensure your schema remains compatible with the latest security and performance features.

    New in Data & Databases

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.

    Free