title: variable relationships within a single query in neo4j
body: <p>I am new to neo4j. I have two types of nodes in the database, i.e., &quot;Person&quot; and &quot;House&quot;. I want to create relationships between each &quot;Person&quot; and the &quot;House&quot; with names like &quot;resident_1&quot;, &quot;resident_2&quot;, etc. Please find my code below:</p>
  <pre><code>CREATE (n1:Person {name: '1'})
  CREATE (n2:Person {name: '2'})
  CREATE (n3:Person {name: '3'})
  CREATE (n4:Person {name: '4'})
  CREATE (t1:House {name:&quot;T1&quot;})
  With n1, n2,n3,n4,t1
  MATCH(a:House{name: &quot;T1&quot;})
  with a
  MATCH(b:Person) 
  WITH a, b
  Create (a)-[r:resident_1]-&gt;(b)
  RETURN type(r)
  </code></pre>
  <p>The output generates</p>
  <pre><code>╒════════════╕
  │&quot;type(r)&quot;   │
  ╞════════════╡
  │&quot;resident_1&quot;│
  ├────────────┤
  │&quot;resident_1&quot;│
  ├────────────┤
  │&quot;resident_1&quot;│
  ├────────────┤
  │&quot;resident_1&quot;│
  └────────────┘
  </code></pre>
  <p>But, I want to generate</p>
  <pre><code>╒════════════╕
  │&quot;type(r)&quot;   │
  ╞════════════╡
  │&quot;resident_1&quot;│
  ├────────────┤
  │&quot;resident_2&quot;│
  ├────────────┤
  │&quot;resident_3&quot;│
  ├────────────┤
  │&quot;resident_4&quot;│
  └────────────┘
  </code></pre>
  <p>How to do that? Any help is highly appreciated. Thanks!</p>