mongodb-schema-design

Designs and reviews MongoDB data models using schema patterns and anti-patterns.

4|Updated Mar 28, 2026
One-click install
npx skills add https://github.com/minexo79/coser-card-maker --skill mongodb-schema-design-minexo79
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb-schema-design
Source: https://github.com/minexo79/coser-card-maker/tree/main/.kilo/skills/mongodb-schema-design
Command: npx skills add https://github.com/minexo79/coser-card-maker --skill mongodb-schema-design-minexo79

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Poor MongoDB schema design causes slow queries, bloated documents, and costly rewrites that indexes alone cannot fix. This Skill provides structured guidance for designing, reviewing, and migrating MongoDB data models before problems reach production. ## Core Features & Use Cases - Embed vs Reference Decisions: Apply a decision framework for one-to-one, one-to-few, one-to-many, many-to-many, and tree/hierarchical relationships based on access patterns. - Anti-Pattern Detection: Identify and fix excessive $lookup usage, unnecessary collections, and redundant indexes flagged by Atlas Performance Advisor. - Design Patterns Library: Apply 11 documented patterns including bucket, computed, outlier, extended reference, document versioning, and time series collections. - Use Case: When migrating a SQL database to MongoDB, use this Skill to denormalize joined tables into rich documents, add $jsonSchema validation, and avoid hitting the 16MB document limit with unbounded arrays. ## Quick Start Ask the assistant to review your MongoDB schema design or help you decide whether to embed or reference a specific relationship in your data model.

Frequently Asked Questions about mongodb-schema-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decide between embedding and referencing in MongoDB?

Embed when data is always accessed together, such as one-to-one or bounded one-to-few relationships like user addresses. Reference when data is accessed independently, relationships are many-to-many, or arrays can grow without bound, such as posts and comments.

How do I migrate a SQL database schema to MongoDB?

Avoid converting tables one-to-one into collections. Identify tables that are always joined together and denormalize them into single documents, keeping separate only what is accessed independently. This enables single-query reads and atomic updates.

What causes the MongoDB 16MB document limit error?

The 16MB BSON limit is typically hit by unbounded arrays, large embedded binaries, or deeply nested objects. Move unbounded data to separate collections with a reference field, and monitor document sizes using the $bsonSize aggregation operator.

How do I find and remove unused indexes in MongoDB?

Run an aggregation with $indexStats to find indexes with zero access counts, then hide the index with hideIndex, monitor for a full workload cycle, and drop it once confirmed safe. A compound index like {a:1, b:1} makes a single-field index {a:1} redundant.

When should I use MongoDB schema validation?

Add $jsonSchema validation when creating new collections or after discovering inconsistent document structures. Start with validationLevel moderate and validationAction warn on existing collections, then tighten to strict and error once violations are resolved.

When should I not embed data in MongoDB documents?

Avoid embedding when arrays grow unbounded, child documents are large relative to the parent, data is queried independently of the parent, or child data has a different lifecycle. Use references or patterns like outlier and bucket instead.