Design Patterns in MongoDB

From the MongoDB cheat sheet · Schema Design & Validation · verified Jul 2026

Design Patterns

Common MongoDB schema design patterns

javascript
// Embedding pattern (denormalization)
{
  _id: ObjectId("..."),
  name: "John Doe",
  addresses: [
    { type: "home", street: "123 Main St", city: "NYC" },
    { type: "work", street: "456 Corp Ave", city: "NYC" }
  ]
}

// Reference pattern (normalization)
// Users collection
{ _id: userId, name: "John", orderIds: [order1, order2] }
// Orders collection  
{ _id: order1, customerId: userId, total: 99.99 }

// Hybrid pattern
{
  _id: postId,
  title: "MongoDB Tips",
  author: {  // Embed frequently needed data
    _id: authorId,
    name: "Jane Doe",
    avatar: "jane.jpg"
  },
  // Reference for full author details
  authorId: authorId
}
💡 Embed for 1:1 or 1:few relationships
📌 Reference for 1:many or many:many
⚡ Denormalization improves read performance
⚠️ Avoid unbounded arrays (use bucketing)
🟢 Essential - Choose pattern based on access patterns
schemapatternsdesign

Continue with MongoDB

Save the full cheat sheet or work through every related task.

More MongoDB tasks

Back to the full MongoDB cheat sheet