title: Finding nodes that have all common intermediaries
body: <p>I'm creating a system in which we match <code>orders</code> to <code>staff</code>. Conceptually, an <code>order</code> is a request for person to do some work, and a <code>staff</code> is a person who can do that work. An <code>order</code> can have one or more <code>requirements</code> (i.e. restrictions on who can do the work), and a <code>staff</code> can have one more more <code>requirements</code> (i.e. qualifications to do work).</p>
  
  <p>I'm attempting to create a cypher query that will give me all <code>staff</code> that have <em>all</em> of the <code>requirement</code>s listed by a given <code>order</code>. Said another way, I'm trying to find all <code>staff</code> nodes that are related to every <code>requirement</code> node that is related to a given <code>order</code> node. <strong>My question is</strong>: how do I create a cypher query to model that business logic?</p>
  
  <p>As an example, consider the following sample data:</p>
  
  <ul>
  <li><a href="http://imgur.com/PEipatA" rel="nofollow">A picture view of my sample data</a></li>
  <li>Alternatively, here is <a href="http://console.neo4j.org/?id=ukzlme" rel="nofollow">an
  interactive console for my data</a></li>
  </ul>
  
  <p>Look at the <em>orderId: 1</em> node. it has a <code>requires</code> relationship to two nodes, labeled <em>RN</em> and <em>ER IV</em>. In order words, order #1 requires any applicants to have the RN qualification and the ER IV qualification. It so happens that staff member <em>Evan</em> (<em>staffId: 1</em>) has both of those qualifications, so he should be able to apply for that job. The staff member <em>Tim</em> has ONE of those requirements, but not both, so he should not be able to apply for that job. Additionally, <em>orderId: 2</em> only has one requirement, which Evan and Tim both have, so they should both be able to apply for that job.</p>
  
  <p>So in essence, if I were to start with order #1 I would want to get back only Evan. If I were to start with order #2 I would want to get back Evan and Tim*.</p>
  
  <p>The following query is half way there. It will give me all unique paths from a given order to a staff member one requirement at a time. However, it does not check that EVERY requirement path is satisfied (which means currently it will only work for orders that only have a single requirement):</p>
  
  <pre><code>start o=node(2) 
  match o-[:requires]-&gt;req&lt;-[:hasRequirement]-s 
  return o, req, s;
  </code></pre>
  
  <p>So what are my options? Can I somehow check the presence of an unknown number of matching relationships? Or will I need to model my data a different way?</p>
  
  <p>*<strong>Edit:</strong> I made a mistake when setting up my sample data. <em>Tim</em> should have been associated with <em>RN</em> so that he qualified for order #2.</p>