- Home
- Skills
- Data & Databases
- Database Design
Works with the AI Agents you already use
Database Design
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
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
- Review the
task.bodyJSONB structure for specific metadata requirements. - Implement Row Level Security (RLS) policies using the
account_idas the tenant discriminator. - 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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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
What's inside
Frequently Asked Questions
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.