title: MongoDb with Java foreign key
body: <p>I need to save two collections in my MongoDB using Java. Where one collection is <strong>Department</strong> and other collection is <strong>Employee</strong>. Where one Department can have many employees I want to save a collection like an employee unique ID has to mapped in my department employee list.</p>
  <p>Example:</p>
  <pre><code>{
      &quot;_id&quot; : ObjectId(&quot;598da19250aa4ad2413d4bc0&quot;),
      &quot;_class&quot; : &quot;com.department&quot;,
      &quot;departmentName&quot; : &quot;SAQ-A&quot;,
      &quot;departmentNumber&quot; : &quot;3_2&quot;,
      &quot;employee&quot; : [ 
             &quot;id&quot; : &quot;1&quot;,
             &quot;id&quot; : &quot;2&quot;,
             &quot;id&quot; : &quot;3&quot;
       ]
  }
  </code></pre>
  <p>Can I know what is the way I can achieve it in MongoDB using Java?</p>