How to model optional relationship


(Monikadhaiya) #1

Please help me model this

Course need some qualification. course sometimes requires any of N qualification. How can I model this scenario?

I was thinking to have a node which can have property "any" or "all" so my model look like

course -----> (any) --------- of N Qualifications
Course ------> (All)---------------> of N Qualifications


(Michael Hunger) #2

your idea sounds good, that property could also have a number

otherwise you might model the "required" information on the relationship

(course)-->(requirement:Requirement:All)-[:NEEDS]->(qualification)
(course)-->(requirement:Requirement:Any)-[:NEEDS]->(qualification)


(Monikadhaiya) #3

Thanks Michael. In your example, Is “Requirement” a node or relationship?


(Andrew Bowman) #4

Hi there, in Cypher, nodes are always in parenthesis, and relationships are in square brackets.