<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Data Modeling
  <a class="headerlink leafygreen-ui-1kepx47" href="#data-modeling" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="data-modeling">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-a5yxub">
  <p class="css-1cmx2d4 ef7gu8j0">
   On this page
  </p>
  <ul class="css-1qb0mst ef7gu8j1">
   <li class="leafygreen-ui-1e7a0ei">
    <a class="lg-ui-0001 leafygreen-ui-e98ikf" href="#use-cases" target="_self">
     <span>
      Use Cases
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#schema-design--differences-between-relational-and-document-databases" target="_self">
     <span>
      Schema Design: Differences between Relational and Document Databases
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#plan-your-schema" target="_self">
     <span>
      Plan Your Schema
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#link-related-data" target="_self">
     <span>
      Link Related Data
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#embedded-data" target="_self">
     <span>
      Embedded Data
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#references" target="_self">
     <span>
      References
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#additional-data-modeling-considerations" target="_self">
     <span>
      Additional Data Modeling Considerations
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#data-duplication-and-consistency" target="_self">
     <span>
      Data Duplication and Consistency
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#indexing" target="_self">
     <span>
      Indexing
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#hardware-constraints" target="_self">
     <span>
      Hardware Constraints
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#single-document-atomicity" target="_self">
     <span>
      Single Document Atomicity
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self">
     <span>
      Learn More
     </span>
    </a>
   </li>
  </ul>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  Data modeling refers to the organization of data within a database and
the links between related entities. Data in MongoDB has a
  <strong>
   flexible schema model
  </strong>
  , which means:
 </p>
 <ul class="leafygreen-ui-rioki0">
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-document">
     Documents
    </a>
    within a single
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-collection">
     collection
    </a>
    are not required to have the same set of fields.
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    A field's data type can differ between documents within a collection.
   </p>
  </li>
 </ul>
 <p class="leafygreen-ui-1kp3ins">
  Generally, documents in a collection share a similar structure. To
ensure consistency in your data model, you can create
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/schema-validation/#std-label-schema-validation-overview">
   schema
validation rules
   <!-- -->
   .
  </a>
 </p>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Use Cases
   <a class="headerlink leafygreen-ui-1kepx47" href="#use-cases" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="use-cases">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   The flexible data model lets you organize your data to match your
application's needs. MongoDB is a document database, meaning you can
embed related data in object and array fields.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   A flexible schema is useful in the following scenarios:
  </p>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     Your company tracks which department each employee works in. You can
embed department information inside of the
     <code class="leafygreen-ui-1l06pbn">
      employee
     </code>
     collection to
return relevant information in a single query.
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     Your e-commerce application shows the five most recent reviews when
displaying a product. You can store the recent reviews in the same
collection as the product data, and store older reviews in a separate
collection because the older reviews are not accessed as frequently.
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     Your clothing store needs to create a single-page application for a
product catalog. Different products have different attributes, and
therefore use different document fields. However, you can store all of
the products in the same collection.
    </p>
   </li>
  </ul>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Schema Design: Differences between Relational and Document Databases
   <a class="headerlink leafygreen-ui-1kepx47" href="#schema-design--differences-between-relational-and-document-databases" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="schema-design--differences-between-relational-and-document-databases">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   When you design a schema for a document database like MongoDB, there are
a couple of important differences from relational databases to consider.
  </p>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <colgroup>
     <col style="width:10%"/>
     <col style="width:10%"/>
    </colgroup>
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Relational Database Behavior
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Document Database Behavior
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         You must determine a table's schema before you insert data.
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Your schema can change over time as the needs of your application
change.
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         You often need to join data from several different tables to
return the data needed by your application.
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         The flexible data model lets you store data to match the way your
application returns data, and avoid joins. Avoiding joins across
multiple collections improves performance and reduces your
deployment's workload.
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Plan Your Schema
   <a class="headerlink leafygreen-ui-1kepx47" href="#plan-your-schema" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="plan-your-schema">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   To ensure that your data model has a logical structure and achieves
optimal performance, plan your schema prior to using your database at a
production scale. To determine your data model, use the following
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/schema-design-process/#std-label-data-modeling-schema-design">
    schema design process
    <!-- -->
    :
   </a>
  </p>
  <ol class="leafygreen-ui-rioki0" type="1">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/schema-design-process/identify-workload/#std-label-data-modeling-identify-workload">
      Identify your application's workload
      <!-- -->
      .
     </a>
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/schema-design-process/map-relationships/#std-label-data-modeling-map-relationships">
      Map relationships between objects in your collections
      <!-- -->
      .
     </a>
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/schema-design-process/apply-patterns/#std-label-data-modeling-apply-patterns">
      Apply design patterns
      <!-- -->
      .
     </a>
    </p>
   </li>
  </ol>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Link Related Data
   <a class="headerlink leafygreen-ui-1kepx47" href="#link-related-data" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="link-related-data">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   When you design your data model in MongoDB, consider the structure of
your documents and the ways your application uses data from related
entities.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   To link related data, you can either:
  </p>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     Embed related data within a single document.
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     Store related data in a separate collection and access it with a
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-data-modeling-reference" target="_self">
      <span>
       reference
       <!-- -->
       .
      </span>
     </a>
    </p>
   </li>
  </ul>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Embedded Data
    <a class="headerlink leafygreen-ui-1kepx47" href="#embedded-data" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="embedded-data">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Embedded documents store related data in a single document structure. A
document can contain arrays and sub-documents with related data. These
    <strong>
     denormalized
    </strong>
    data models allow applications to retrieve related data
in a single database operation.
   </p>
   <div class="figure css-5vkxs0" style="width:720px">
    <img alt="Data model with embedded fields that contain all related information." class="leafygreen-ui-1qnf57e" height="350" src="/docs/manual/images/data-model-denormalized.bakedsvg.svg" style="--border-color:#C1C7C6" width="620"/>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    For many use cases in MongoDB, the denormalized data model is optimal.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    To learn about the strengths and weaknesses of embedding documents, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/concepts/embedding-vs-references/#std-label-data-modeling-embedding">
     Embedded Data Models
     <!-- -->
     .
    </a>
   </p>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-data-modeling-reference">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    References
    <a class="headerlink leafygreen-ui-1kepx47" href="#references" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="references">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    References store relationships between data by including links, called
    <strong>
     references
    </strong>
    , from one document to another. For example, a
    <code class="leafygreen-ui-1l06pbn">
     customerId
    </code>
    field in an
    <code class="leafygreen-ui-1l06pbn">
     orders
    </code>
    collection indicates a reference
to a document in a
    <code class="leafygreen-ui-1l06pbn">
     customers
    </code>
    collection.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    Applications can resolve these references to access the related data.
Broadly, these are
    <em>
     normalized
    </em>
    data models.
   </p>
   <div class="figure css-5vkxs0" style="width:720px">
    <img alt="Data model using references to link documents. Both the ``contact`` document and the ``access`` document contain a reference to the ``user`` document." class="leafygreen-ui-1qnf57e" height="450" src="/docs/manual/images/data-model-normalized.bakedsvg.svg" style="--border-color:#C1C7C6" width="740"/>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    To learn about the strengths and weaknesses of using references, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/concepts/embedding-vs-references/#std-label-data-modeling-referencing">
     References
     <!-- -->
     .
    </a>
   </p>
  </section>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Additional Data Modeling Considerations
   <a class="headerlink leafygreen-ui-1kepx47" href="#additional-data-modeling-considerations" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="additional-data-modeling-considerations">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   The following factors can impact how you plan your data model.
  </p>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Data Duplication and Consistency
    <a class="headerlink leafygreen-ui-1kepx47" href="#data-duplication-and-consistency" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="data-duplication-and-consistency">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    When you embed related data in a single document, you may duplicate data
between two collections. Duplicating data lets your application query
related information about multiple entities in a single query while
logically separating entities in your model.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    For example, a
    <code class="leafygreen-ui-1l06pbn">
     products
    </code>
    collection stores the five most recent
reviews in a product document. Those reviews are also stored in a
    <code class="leafygreen-ui-1l06pbn">
     reviews
    </code>
    collection, which contains
    <em>
     all
    </em>
    product reviews. When a new
review is written, the following writes occur:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The review is inserted into the
      <code class="leafygreen-ui-1l06pbn">
       reviews
      </code>
      collection.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The array of recent reviews in the
      <code class="leafygreen-ui-1l06pbn">
       products
      </code>
      collection is updated
with
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/pop/#mongodb-update-up.-pop">
       <code class="leafygreen-ui-1l06pbn">
        $pop
       </code>
      </a>
      and
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/push/#mongodb-update-up.-push">
       <code class="leafygreen-ui-1l06pbn">
        $push
       </code>
       .
      </a>
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    If the duplicated data is not updated often, then there is minimal
additional work required to keep the two collections consistent.
However, if the duplicated data is updated often, using a
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-data-modeling-reference" target="_self">
     <span>
      reference
     </span>
    </a>
    to link related data may be a
better approach.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    Before you duplicate data, consider the following factors:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      How often the duplicated data needs to be updated.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The performance benefit for reads when data is duplicated.
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    To learn more, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/handle-duplicate-data/#std-label-data-modeling-duplicate-data">
     Handle Duplicate Data
     <!-- -->
     .
    </a>
   </p>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Indexing
    <a class="headerlink leafygreen-ui-1kepx47" href="#indexing" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="indexing">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    To improve performance for queries that your application runs
frequently, create
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/indexes/#std-label-indexes">
     indexes
    </a>
    on commonly queried fields.
As your application grows,
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/measure-index-use/#std-label-indexes-measuring-use">
     monitor your deployment's index use
    </a>
    to ensure that your indexes are still
supporting relevant queries.
   </p>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Hardware Constraints
    <a class="headerlink leafygreen-ui-1kepx47" href="#hardware-constraints" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="hardware-constraints">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    When you design your schema, consider your deployment's hardware,
especially the amount of available RAM. Larger documents use more RAM,
which may cause your application to read from disk and degrade
performance. When possible, design your schema so only relevant fields
are returned by queries. This practice ensures that your application's
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-working-set">
     working set
    </a>
    does not grow unnecessarily large.
   </p>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Single Document Atomicity
    <a class="headerlink leafygreen-ui-1kepx47" href="#single-document-atomicity" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="single-document-atomicity">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    In MongoDB, a write operation is atomic on the level of a single
document, even if the operation modifies multiple embedded documents
within a single document. This means that if an update operation
affects several sub-documents, either all of those sub-documents are
updated, or the operation fails entirely and no updates occur.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    A denormalized data model with embedded data combines all related data
in a single document instead of normalizing across multiple documents
and collections. This data model allows atomic operations, in contrast
to a normalized model where operations affect multiple documents.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    For more information see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/data-model-operations/#std-label-data-model-atomicity">
     Atomicity
     <!-- -->
     .
    </a>
   </p>
  </section>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Learn More
   <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="learn-more">
    </div>
   </a>
  </h2>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     Learn how to structure documents and define your schema in
MongoDB University's
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://learn.mongodb.com/learning-paths/data-modeling-for-mongodb" target="_self">
      <span>
       Data Modeling
      </span>
     </a>
     course.
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     For more information on data modeling with MongoDB, download the
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/modernize?tck=docs_server" target="_self">
      <span>
       MongoDB Application Modernization Guide
      </span>
     </a>
     .
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The download includes the following resources:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Presentation on the methodology of data modeling with MongoDB
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       White paper covering best practices and considerations for
migrating to MongoDB from an
       <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-RDBMS">
        RDBMS
       </a>
       data model
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Reference MongoDB schema with its RDBMS equivalent
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Application Modernization scorecard
      </p>
     </li>
    </ul>
   </li>
  </ul>
 </section>
</section>
