title: Create multiple nodes and relationships in several Cypher statements
body: <p>I want to create multiple neo4j nodes and relationships in one Cypher transaction. I'm using py2neo which <a href="http://py2neo.org/2.0/cypher.html#transactions" rel="nofollow">allows issuing multiple Cypher statements in one transaction</a> .</p>
  
  <p>I thought I'd add a statement for each node and relationship I create:</p>
  
  <pre><code>tx.append('CREATE (n:Label { prop: val })')
  tx.append('CREATE (m:Label { prop: val2 })')
  </code></pre>
  
  <p>Now I want to create a relationship between the two created nodes:</p>
  
  <pre><code>tx.append('CREATE (n)-[:REL]-&gt;(m)')
  </code></pre>
  
  <p>This doesn't work as expected. No relationship is created between the first two nodes, since there's no <code>n</code> or <code>m</code> in the context of the last statement (there is a new relationship between two <em>new</em> nodes - four nodes are created in total)</p>
  
  <p>Is there a way around this? Or should I combine all the calls to CREATE (around 100,000 per logical transaction) in one statement? </p>
  
  <p>It just hurts my brain thinking about such a statement, because I'll need to store everything on one big StringIO, and I lose the ability to use Cypher query parameters - I'll need to serialize dictionaries to text myself.</p>
  
  <p>UPDATE:
  The actual graph layout is more complicated than that. I have multiple relationship types, and each node is connected to at least two other nodes, while some nodes are connected to hundreds of nodes.</p>