title: Returning sets of lists in graph databases
body: <p>This is a follow-on question from <a href="https://stackoverflow.com/q/49625522/781965">How to model relationships between sets of nodes</a>. I'll repeat the blurb in case that question gets removed or changed substantially:</p>
  
  <p>I am currently looking at modelling tertiary courses and other such entities (MATH101, BIOL360, BSc etc.), and one of the options we're looking at is graph databases. I am not familiar with graph databases, other than in theory.</p>
  
  <p>One of the use cases for this database is to query possible pathways through the courses; for example, answering the question "what minimum combinations of courses are valid to fulfill the requirements to receive a Bachelor of Science in Computer Science with Honours?". Some of the requirements will be simple (the qualification requires you've done Comp101, Math101 and Comp201) and some will provide options (require you've done 80 points of papers classified as "science" papers at the 100 level or above).</p>
  
  <p>I found <a href="https://neo4j.com/docs/developer-manual/current/cypher/syntax/lists/" rel="nofollow noreferrer">neo4j lists</a> which I thought were really promising, but what I really seem to want is to be able to return a list of lists, where each component list represents a single potential pathway. I don't see a way to generate such a list of lists though, so I'm guessing I've got something wrong at the conceptual level.</p>
  
  <p>One way I could do this is have a loop that looks at the qualification node, grabs one possible combination of nodes, recursively fulfills the requirements of that node, and then moves onto the next possible combination. As a database developer, the idea of using a loop for what is clearly theoretically solvable as a set-based operation is the kind of thing that keeps me from sleeping easily at night, so I will go to great lengths to avoid such an abomination. <strong>How can I construct a query to build such a set of sets?</strong></p>
  
  <p>Again, I've tagged Neo4J because I'm leaning towards it as (from what I can tell) it's the most widely known/used graph dbms (and i've had quite an elegant solution to my previous question that works in that), but I'm open to solutions in other databases too (in fact, if it's possible in the very new SQL Server offering, that would probably be ideal as other infrastructure is on that).</p>