Skip to content
Back to skills

Design Database Schema

ASecurity

Designs a relational schema from requirements and access patterns, with keys, constraints, types, indexes and DDL. Use when starting a new service or feature that stores data.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 26, 2026
ai-agentsgosqldatabase

Security analysis

A100/100

Scanned November 26, 2026

npx -y skills add hermes-hq/hodios-dist --skill design-database-schema --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Design Database Schema?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Design Database Schema
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hermes-hq-design-database-schema/badge)](https://www.skillsdirectory.com/skills/hermes-hq-design-database-schema)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: design-database-schema
description: Designs a relational schema from requirements and access patterns, with keys, constraints, types, indexes and DDL. Use when starting a new service or feature that stores data.
license: CC0-1.0
arguments:
  - requirements
  - access_patterns
  - database
argument-hint: <requirements> [access_patterns] [database]
disable-model-invocation: true
metadata:
  version: 1.0.1
  kind: prompt
  category: data
  source: https://hermes-ide.com/prompts/design-database-schema
  catalog: 2026.1014.1
---

# Design a relational database schema

## Inputs

- `requirements` (required): What the system must store and do. Entities, rules, volumes, retention and any multi-tenancy.
- `access_patterns` (optional): The main reads and writes with rough frequency, for example "list a customer's last 20 orders, 200/s".
- `database` (optional; one of: postgres, mysql, sqlite, sql-server, other; default: postgres): Target database engine.

Arguments fill these in order. If a required value is empty, take it from the user’s message or ask for it once.

<context>
A schema outlives the code around it. Mistakes such as a missing constraint, money stored as a float, a timestamp without a time zone or a tenant key left out of an index are cheap on day one and expensive after a year of data. The database should enforce the rules it can, so bad data cannot get in through any code path.
</context>

<task>
Design a $database schema for:
$requirements
Only if access_patterns was provided: 
Access patterns:
$access_patterns

1. List the entities, their relationships and cardinalities, and the business rules the data must obey. Write down every assumption you make.
2. Model to third normal form first. Denormalise only where a listed access pattern needs it, and say which one.
3. Choose keys: a surrogate primary key (identity integer, or a time-ordered UUID when ids are created outside the database or exposed publicly), plus natural unique keys as `UNIQUE` constraints.
4. Choose types deliberately: exact decimals for money (with the currency stored alongside), time-zone-aware timestamps, text with `CHECK` constraints or lookup tables for small fixed sets, and JSON only for data that is genuinely schemaless.
5. Enforce rules in the database: `NOT NULL` by default, foreign keys with an explicit `ON DELETE` behaviour, `UNIQUE` and `CHECK` constraints.
6. Derive indexes from the access patterns, one per pattern at most, with column order explained. Index foreign keys used in joins or cascading deletes.
7. For multi-tenant data, put the tenant key in every tenant-owned table, in its unique constraints and first in its indexes.
</task>

<constraints>
- Model only what the requirements need. Add audit columns, soft deletes or history tables only when a requirement asks for them, and list them under Trade-offs as options otherwise.
- Use DDL that runs on $database as written. Do not mix dialects.
- Every index maps to a named access pattern or foreign key.
- When a requirement is ambiguous in a way that changes the model (one-to-many or many-to-many, hard or soft delete), pick one, say so in Assumptions, and add the question to Open questions.
- Separate what you verified from what you inferred. Mark inferences as such.
- When you do not know, say "I don't know" once and state what would settle it.
</constraints>

<output_format>
## Assumptions
Numbered.

## Diagram
A Mermaid `erDiagram` with every table, key and relationship.

## DDL
One SQL code block that creates every table, constraint and index in dependency order.

## Access patterns
| Pattern | Query shape | Index used |

## Trade-offs
Each significant choice, the alternative, and why you chose this one.

## Open questions
Questions whose answers would change the schema. "None" if none.
</output_format>

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.