Creative & DesignIntermediate
mongodb-schema-design
Design efficient document schemas with validation and indexing patt...
Developer Setup
Setup & Installation
bash
npx skills add https://github.com/mongodb/agent-skills --skill mongodb-schema-designnpx skills add https://github.com/mongodb/agent-skills --skill mongodb-schema-designOr paste this URL into your assistant to install:
Overview
What This Skill Does
Design efficient document schemas with validation and indexing patterns
Application
When to use this Skill
- Integrating mongodb schema design into your development workflow.
- Following best practices for design efficient document schemas with validation and indexing patterns.
- Automating repetitive tasks with AI-assisted tooling.
- Building production-grade applications with proper standards.
- Debugging and troubleshooting common implementation issues.
Documentation
Show Skills.md file
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
- antipattern-unnecessary-collections - Splitting homogeneous data into multiple collections is often an anti-pattern; consult this reference to validate whether this is the case.
- antipattern-excessive-lookups - When encountering overly normalized collections that reference each other or frequent and possibly slow $lookup operations, consult this reference to validate whether this is problematic and how to fix it.
- antipattern-unnecessary-indexes - Consult this reference when indexes overlap or are not used by queries, to identify and remove unnecessary indexes that add overhead without benefit.
Lines 1 - 25 of 133
Recommendations