Skip to content
Agentmart
Submit a tool

database-design

Designs database schemas, migration strategies, indexing, query optimization, and ORM patterns.

Skill by The13thNode

IndexedMIT★ 3
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/the13thnode-database-design

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Designs database schemas, migration strategies, indexing, query optimization, and ORM patterns. Use when a team needs to design a data model, plan database migrations safely, optimize slow queries, choose between SQL and NoSQL, set up multi-tenancy, or implement soft delete patterns. Trigger for "design the database", "data model", "schema", "migration", "indexes", "slow queries", "Prisma", "Drizzle", "multi-tenancy", or "database architecture". Part of the Founder OS suite — the data layer hat.

Use cases: design, backend, data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/database-design

What's inside

Skill name
database-design
Description
Designs database schemas, migration strategies, indexing, query optimization, and ORM patterns. Use when a team needs to design a data model, plan database migrations safely, optimize slow queries, choose between SQL and NoSQL, set up multi-tenancy, or implement soft delete patterns. Trigger for "design the database", "data model", "schema", "migration", "indexes", "slow queries", "Prisma", "Drizzle", "multi-tenancy", or "database architecture". Part of the Founder OS suite — the data layer hat.
License
MIT
Instructions
307 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Database Design — Founder OS

The database schema is the hardest thing to change after launch. Get it right upfront. Every structural change after users have data costs exponentially more than designing it correctly first.

---

## Core Design Principles

1. **Normalise first, denormalise intentionally** — start with clean relational design, add denormalisation only when you have proven query performance problems
2. **Soft delete by default** — never hard-delete user data without a retention policy
3. **Audit columns on every table** — `created_at`, `updated_at`, `deleted_at`
4. **UUID primary keys** — not auto-increment integers (security + distributed systems)
5. **Foreign key constraints in the database** — don't rely on application logic alone

---

## Base Schema Pattern

```sql
-- Every table inherits this structure
CREATE TABLE [table_name] (
  -- Primary key
  id            UUID PRIMARY KEY DEFAULT gen_random_uuid(),

  -- Audit columns (always present)
  created_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  updated_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  deleted_at    TIMESTAMPTZ,              -- NULL = active, timestamp = soft deleted

  -- Foreign keys (as needed)
  org_id        UUID NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
  created_by    UUID REFERENCES users(id) ON DELETE SET NULL,

  -- Domain columns
  [column]      [type] NOT NULL,
  [column]      [type],                   -- Nullable = truly optional
);

-- Auto-update updated_at on every update
CREATE TRIGGER update_[table]_updated_at
  BEFORE UPDATE ON [table_name]
  FOR EACH ROW
  EXECUTE FUNCTION update_updated_at_column();
```

---

## Multi-Tenancy Patterns

Choose based on your security and scale requirements:

### Pattern 1: Shared Database, Shared Schema (RLS)
```sql
-- Every table has org_id
-- Row Level Security filters automatically

ALTER TABLE [table] ENABLE ROW LEVEL SECURITY;

CREATE POLICY tenant_isolation ON [table]
  USING (org_id = current_setting('app.current_org_id')::UUID);

-- In application: SET app.current_org_id = '[org_id]';
```
**Best for**: Startups, cost-sensitive, simpler operations

### Pattern 2: Shared Database, Separate Schemas
```sql
-- Each tenant gets their own schema
CREATE SCHEMA tenant_[org_id];
CREATE TABLE tenant_[org_id].users (...);
```
**Best for**: Mid-market, moderate isolation needs

### Pattern 3: Separate Databases
Each tenant gets their own database instance.
**Best for**: Enterprise, high compliance (HIPAA, financial), high-value contracts

---

## Common Schema Patterns

### Users & Authentication
```sql
CREATE TABLE users (
  id            UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  email         TEXT UNIQUE NOT NULL,
  email_verified BOOLEAN NOT NULL DEFAULT false,
  name          TEXT,
  avatar_url    TEXT,
  created_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  updated_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  deleted_at    TIMESTAMPTZ
);

CREATE TABLE user_sessions (
  id            UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id       UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  token_hash    TEXT NOT NULL UNIQUE,   -- Never store raw tokens
  expires_at    TIMESTAMPTZ NOT NULL,
  created_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  last_used_at  TIMESTAMPTZ
);

CREATE INDEX idx_sessions_user_id ON user_sessions(user_id);
CREATE INDEX idx_sessions_expires ON user_sessions(expires_at);
```

### Organizations (Multi-tenant B2B)
```sql
CREATE TABLE organizations (
  id            UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name          TEXT NOT NULL,
  slug          TEXT UNIQUE NOT NULL,   -- For URLs: acme-corp
  plan          TEXT NOT NULL DEFAULT 'free',
  created_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  updated_at    TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE org_members (

From The13thNode/VibeCorp_PromptCEO, MIT.

More from The13thNode/VibeCorp_PromptCEO

Signals

Stars
3
Forks
0
Open issues
0
Last commit (this folder)
Mar 26, 2026 (7 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from The13thNode

Cite this page

database-design skill. Agent Mart. https://agentmart.dev/skills/the13thnode-database-design (last updated 2026-10-24)