title: mongodb - storing relation with id
body: <p>I have a very basic (might be sily) question.<br />
  Suppose I am having product collection with list of product as below.</p>
  <pre><code>db.products.findOne
  {
      &quot;_id&quot; : ObjectId(&quot;60db1b449f9a43695c4bb461&quot;),
      &quot;name&quot; : &quot;product 1&quot;
  }
  </code></pre>
  <p>while storing category as a relation, how should it be stored? (Please check the category_id)</p>
  <p>approach 1</p>
  <pre><code>db.products.findOne
  {
      &quot;_id&quot; : ObjectId(&quot;60db1b449f9a43695c4bb461&quot;),
      &quot;name&quot; : &quot;product 1&quot;,
      &quot;category_id&quot; : ObjectId(&quot;608f981fcfeaa757ca69b4b5&quot;)
  }
  </code></pre>
  <p>approach 2</p>
  <pre><code>db.products.findOne
  {
      &quot;_id&quot; : ObjectId(&quot;60db1b449f9a43695c4bb461&quot;),
      &quot;name&quot; : &quot;product 1&quot;,
      &quot;category_id&quot; : &quot;608f981fcfeaa757ca69b4b5&quot;
  }
  </code></pre>