New advertisers: 50% off your first month with code FIRSTMONTHSee slots
mongodb avatar

Mongodb Schema Design

Schema design patterns and anti-patterns for MongoDB, covering when to embed versus reference data.

skills.sh installs
7.4K
GitHub stars
207
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers antipatterns (unnecessary collections, excessive $lookup, unnecessary indexes), fundamentals (embed vs reference, document model, validation, 16MB size), and 11 design patterns
  • Includes an access pattern analysis workflow that combines query stats, slow query logs, codebase review, and user input before recommending changes
  • Enforces a principle that data accessed together should be stored together, reserving references for cases where embedding is not viable
  • Designed for developers designing new MongoDB data models, migrating from SQL, or troubleshooting schema-driven performance issues

Install

$ npx -y skills add mongodb/agent-skills --skill mongodb-schema-design -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

MongoDB Schema Design

Data modeling patterns and anti-patterns for MongoDB, maintained by MongoDB. Bad schema is the root cause of most MongoDB performance and cost issues—queries and indexes cannot fix a fundamentally wrong model.

When to Apply

Reference these guidelines when:

  • Designing a new MongoDB schema from scratch
  • Migrating from SQL/relational databases to MongoDB
  • Reviewing existing data models for performance issues
  • Troubleshooting slow queries or growing document sizes
  • Deciding between embedding and referencing
  • Modeling relationships (one-to-one, one-to-many, many-to-many)
  • Implementing tree/hierarchical structures
  • Seeing Atlas Schema Suggestions or Performance Advisor warnings
  • Hitting the 16MB document limit
  • Adding schema validation to existing collections

Quick Reference

1. Schema Anti-Patterns - 3 rules

Details

Repository
github.com/mongodb/agent-skills
Category
Databases
First seen
May 16, 2026

More from mongodb/agent-skills

All 8

Similar to Mongodb Schema Design

More Databases