title: Storing a graph in mongodb
body: <p>I have an undirected graph where each node contains an array. Data can be added/deleted from the array. What's the best way to store this in Mongodb and be able to do this query effectively: given node A, select all the data contained in the adjacent nodes of A.</p>
  
  <p>In relational DB, you can create a table representing the edges and another table for storing the data in each node this so.</p>
  
  <pre><code>table 1 
  NodeA, NodeB
  NodeA, NodeC
  
  table 2 
  NodeA, item1
  NodeA, item2
  NodeB, item3 
  </code></pre>
  
  <p>And then you join the tables when you query for the data in adjacent nodes. But join is not possible in MongoDB, so what's the best way to setup this database and efficiently query for data in adjacent nodes (favoring performance slightly over space).</p>