database-decision

Guide developers through choosing the right database BEFORE writing any code. Covers SQL (PostgreSQL, MySQL), NoSQL document (MongoDB), graph (Neo4j), key-value (Redis), wide-column (Cassandra), object-oriented (IRIS), time-series (InfluxDB), and polyglot persistence. ALWAYS use this skill when: user asks "which database should I use", starts building without mentioning a DB choice, compares databases (MongoDB vs PostgreSQL), designs system architecture, mentions CAP theorem / ACID vs BASE / sharding / replication, says "I need a database for...", builds e-commerce / IoT / social / analytics / real-time systems, mentions "store data" / "persist data" / "data layer" / "polyglot persistence". Even if the user already picked a database, STOP and validate that choice before helping implement it. The wrong database is the most expensive technical debt.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "database-decision" with this command: npx skills add lviladrich/database-decision/lviladrich-database-decision-database-decision

Database Decision Framework

CRITICAL: DECIDE BEFORE YOU CODE

STOP. Before writing any database code, schema, or query — justify the choice first. Perfect code on the wrong foundation is technical debt from day one.

STEP 1: GATHER REQUIREMENTS

Ask the user if not provided:

  • Data shape: structured / semi-structured / graph / time-series / objects?
  • Schema stability: fixed or frequently changing?
  • Read/Write ratio: read-heavy, write-heavy, balanced?
  • Volume & scale: MBs→PBs? Users: tens→millions? Single region or global?
  • Consistency needs: strict ACID required? Eventual consistency acceptable?
  • Business: team expertise, budget, existing infra, time pressure?

STEP 2: SELECTION MATRIX

Relational (PostgreSQL, MySQL) → STRUCTURED + STRONG CONSISTENCY

Choose when: stable schema, ACID mandatory, complex JOINs, referential integrity critical. CAP: CA. Signals: "users table", "orders", "bank transactions", "billing", "ERP". AVOID: schema changes often, hierarchical data, need 100s of nodes, millions writes/sec.

Document (MongoDB) → FLEXIBLE SCHEMA + HIERARCHICAL DATA

Choose when: variable attributes per record, nested/JSON data, schema evolves fast, need sharding. CAP: CP. Sharding: by range, hash, or geographic. Signals: "product catalog", "user profiles", "CMS", "different fields per record". AVOID: highly relational with many JOINs, simple key-value pairs.

Key-Value (Redis) → SPEED + SIMPLE ACCESS

Choose when: sub-millisecond latency, get/set by key, caching, sessions, counters, leaderboards, queues. CAP: CP (cluster). Structures: Strings, Lists, Sets, Hashes, Sorted Sets, Streams. Signals: "cache", "sessions", "real-time", "leaderboard", "rate limiter", "shopping cart". AVOID: data exceeds RAM, complex queries needed, need persistent-first storage.

Graph (Neo4j) → RELATIONSHIP-CENTRIC DATA

Choose when: relationships ARE the value, path-finding, recommendations, fraud detection, social networks. CAP: CA. Clustering: Core servers (Raft, M=2F+1) + Read Replicas. Causal consistency. Signals: "relationships", "recommendations", "fraud", "knowledge graph", "who knows whom". AVOID: massive distributed writes, tabular data without relationships, bulk updates on millions of nodes.

Wide-Column (Cassandra) → MASSIVE WRITES + GLOBAL DISTRIBUTION

Choose when: write-heavy (IoT, logs, metrics), multi-datacenter, known query patterns, linear scaling, zero downtime. CAP: AP. Consistency tuning: R+W>N = strong; W=1,R=N = fast writes; Quorum: W>N/2. Signals: "IoT", "sensor data", "event log", "metrics", "multi-region", "always available". AVOID: ad-hoc queries, JOINs, unpredictable read patterns, frequently changing data model.

Object DB (InterSystems IRIS) → COMPLEX OBJECT PERSISTENCE

Choose when: deep OOP hierarchies, no ORM needed, complex domains (healthcare, finance, manufacturing). Signals: "complex objects", "inheritance", "medical records", "financial instruments", "multi-model". AVOID: simple structures, need max horizontal scaling, open-source requirement.

Time-Series (InfluxDB) → TIME-INDEXED DATA + ANALYTICS

Choose when: data indexed by time, monitoring/metrics/IoT, downsampling, retention policies, scientific data. Indexing: R-trees, KD-trees, LSM-trees. Compression: 90%+ reduction. Signals: "metrics", "monitoring", "Grafana", "dashboards", "sensor data over time". AVOID: data not time-indexed, need relationships, general-purpose CRUD.

STEP 3: POLYGLOT PERSISTENCE

Most real systems need multiple databases. For each component independently ask: what's the data shape, access pattern, consistency need, and performance requirement?

Classic E-Commerce (Polyglot)

ComponentDBWhy
Users & AuthPostgreSQLACID, strong consistency, stable schema
Product CatalogMongoDBVariable attributes, flexible schema
Shopping CartRedisSub-ms latency, temporary, high concurrency
RecommendationsNeo4jGraph traversal: "users who bought X also bought Y"
Order HistoryCassandraHigh writes, time-partitioned, multi-region
System MetricsInfluxDBTime-indexed, downsampling, dashboards

ACID vs BASE by Component

  • ACID required: user accounts, payments, orders, inventory
  • BASE acceptable: recommendations, caches, sessions, analytics, feeds

STEP 4: JUSTIFICATION TEMPLATE

ALWAYS produce this for every database choice:

COMPONENT: [Name]
DATABASE: [Technology] ([Type])
DATA: shape, volume, schema stability
ACCESS: R/W ratio, query type, latency need
CONSISTENCY: ACID/eventual/tunable — CAP priority
SCALE: vertical/horizontal, distribution
REJECTED ALTERNATIVES: [why each was worse]
TRADE-OFFS ACCEPTED: [what you sacrifice and why]

STEP 5: ANTI-PATTERNS — STOP THE USER

  • "MongoDB for everything" → Not a relational replacement. Push back if JOINs/ACID needed.
  • "PostgreSQL for everything" → Not optimal for graph traversals, massive writes, sub-ms caching, or variable schemas at scale.
  • "Redis as primary DB" → It's a cache. Always pair with persistent store.
  • "Neo4j for tabular data" → No benefit without relationship traversal.
  • "Cassandra for ad-hoc queries" → Requires one table per query pattern. Unknown patterns = pain.
  • "Single DB for complex system" → 3+ different access patterns = suggest polyglot.
  • "Choosing by popularity" → "Everyone uses X" is not a justification. Defend with data shape + access patterns.

RESPONSE BEHAVIOR

  1. NEVER jump to code. Start with decision framework.
  2. Ask clarifying questions if ambiguous (STEP 1).
  3. Recommend type first, then specific technology.
  4. Always produce justification (STEP 4), even for simple cases.
  5. Suggest polyglot when appropriate (STEP 3).
  6. Call out anti-patterns proactively (STEP 5).
  7. Only after justification, help with schemas/queries/code.
  8. If user already chose, validate against requirements first.

QUICK REFERENCE

  • "I need ACID" → PostgreSQL/MySQL
  • "Schema changes a lot" → MongoDB
  • "Need it in <1ms" → Redis
  • "Relationships ARE my data" → Neo4j
  • "Millions writes/sec, global" → Cassandra
  • "Complex objects with inheritance" → IRIS
  • "Time-indexed metrics" → InfluxDB
  • "3+ different data needs" → Polyglot architecture

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated
Coding

ai-dating

This skill enables dating and matchmaking workflows. Use it when a user asks to make friends, find a partner, run matchmaking, or provide dating preferences/profile updates. The skill should execute `dating-cli` commands to complete profile setup, task creation/update, match checking, contact reveal, and review.

Archived SourceRecently Updated