I am new to Neo4j and Cypher and while converting our Company's Relational DB to Graph Based Model I encountered a problem and I would appreciate any answer.
I have nodes with type person in my model like this:
(:Person {Fname: 'John', catID: 1})
(:Person {Fname: 'George', catID: 2})
(:Person {Fname: 'Natalie', catID: 3})
......
I also have time based Category nodes like this:
(:Category {Id: 1, Date: '2015-02-05'})
(:Category {Id: 1, Date: '2015-01-05'})
(:Category {Id: 1, Date: '2015-03-10'})
(:Category {Id: 3, Date: '2014-03-10'})
(:Category {Id: 3, Date: '2015-05-10'})
......
Now I want to created direct edges from each person to the node in its category with minimum date. What I mean in the above example:
(:Person {Fname: 'John', catID: 1}) ---> (:Category {Id: 1, Date: '2015-01-05'})
(:Person {Fname: 'Natalie', catID: 3}) ---> (:Category {Id: 3, Date: '2014-03-10'})
and after that, I want to create directed edges between nodes in each category based on their Date property in an ascending order. I mean:
(:Category {Id: 1, Date: '2015-01-05'}) ---> (:Category {Id: 1, Date: '2015-02-05'}) ---> (:Category {Id: 1, Date: '2015-03-10'})
(:Category {Id: 3, Date: '2014-03-10'}) ---> (:Category {Id: 3, Date: '2015-05-10'})
What is the cypher code required to do these things. Thanks a lot in advance