title: How to query different collections having a relationship?
body: <p>Applied technologies: Python, MongoEngine, MongoDB.</p>
  
  <p>Recently I started to create a program that the data was originally stored in a relational database.
  All data came to me as CSV files, so I have imported these files using <strong>mongoimport</strong> command line tool. It worked fine and now I have documents like:</p>
  
  <pre><code>people_collection (people.csv file):
  
  {
   id: MongoDB ID("84932809849329043"),
   person_id: 1
   name: Foo
  }
  addresses_collection (addresses.csv file):
  {
   id: MongoDB ID("904389408904311"),
   addresses_id: 1,
   addresses_info: street 1 number 100, turkey,
   person_id: 1
  }
  {
   id: MongoDB ID("72910890434331"),
   addresses_id: 2,
   addresses_info: street 1999 number 595, japan,
   person_id: 1
  }
  </code></pre>
  
  <p>I think I could accomplish this by issuing Manual Reference (described in the mongo docs reference) following this workflow:</p>
  
  <p>1 - query all people I want:</p>
  
  <pre><code>people = [1, 2]
  </code></pre>
  
  <p>2 - query all addresses of the people with id 1, 2 I want:</p>
  
  <pre><code>people_addresses = {1: list_of_addresses_person_1, 2: list_of_addresses_person_2}
  </code></pre>
  
  <p>What is the good way to go?</p>