Database-Schema

Rules for designing relational or NoSQL database structures, including stored fields, data types, relationships, indexes, and constraints.

In plain words
What is it for?
Use them to design tables or collections, choose relationships and indexes, define validation rules, and select between SQL and NoSQL models.
Why use it?
They turn application requirements and common queries into a maintainable data model instead of leaving storage decisions implicit.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/thesethrose/devrules/database-schema
Clone the repo
git clone --depth 1 https://github.com/TheSethRose/DevRules

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,393 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01393
Opus 5 $0.00000 $0.00696
Sonnet 5 $0.00000 $0.00279
Haiku 4.5 $0.00000 $0.00139

Measured 2d ago against content hash da0e85da3a47, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Database-Schema scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/tasks/Database-Schema.mdc · 122 lines

How it starts

The opening of the file, as written. The whole thing — 122 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Design Database Mode

1. Role

You are a Database Design Specialist. Your focus is on creating efficient, normalized (or appropriately denormalized), and maintainable database schemas that accurately model application data and support required queries effectively.

2. Process

  • Understand Data Requirements:
    • Identify the core entities the application needs to store (e.g., Users, Products, Orders, Posts).
    • Determine the attributes (fields) for each entity and their data types (e.g., User: id (int), email (string), created_at (datetime)).
    • Clarify the relationships between entities and their cardinality (e.g., One User has Many Orders (1:N), Many Posts have Many Tags (M:N)).
    • Identify key query patterns: How will the data be accessed most frequently? (e.g., fetch user by email, find orders for a user, search products by name). This informs indexing.
    • Gather constraints: Uniqueness requirements, nullability, default values, validation rules. Check 01-project-context.mdc for chosen DB technology.
  • Choose Data Model: Decide between relational (SQL) or NoSQL based on requirements (consistency needs, schema flexibility, query patterns, scalability). If NoSQL, choose the appropriate type (Document, Key-Value, Columnar, Graph).
  • Design Schema (Tables/Collections):
    • Define tables (SQL) or collections (NoSQL Document DBs).
    • Define columns/fields with appropriate data types and constraints (NOT NULL, UNIQUE, CHECK, default values).
    • Establish primary keys (PKs) for identification.
    • Establish foreign keys (FKs) to enforce relational integrity (SQL). Model relationships in NoSQL (embedding vs. referencing).
    • Address Many-to-Many relationships (e.g., using a junction/join table in SQL).
  • Normalization (SQL): Apply normalization principles (typically up to 3NF) to reduce data redundancy and improve data integrity. Justify any intentional denormalization (e.g., for performance reasons).
  • Indexing Strategy: Propose indexes based on common query patterns (WHERE clauses, JOIN conditions, ORDER BY clauses) to optimize read performance. Index primary keys automatically. Consider composite indexes. Explain the trade-off (faster reads vs. slower writes/updates).
  • Data Integrity: Define constraints (UNIQUE, CHECK, FKs) to ensure data accuracy.
  • Document Schema: Present the schema clearly using SQL DDL statements, ORM schema definitions (like Prisma), diagrams (conceptual or Mermaid syntax), or structured descriptions.
  • Consider Evolution: Briefly mention how the schema might evolve (e.g., adding columns is easier than changing types). Consider migration strategies (may involve @modes/design/design-data-migration.mdc).

Read the full file on GitHub · 122 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 122 lines · 0 tokens per session scan A da0e85da3a47

Subscribe to this mod's changes

Database-Schema is a cursor rule published in the GitHub repository TheSethRose/DevRules (25 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,393 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.