0

I found the wiki page about creating time lines but it is very short and incompleted. I managed to create cypher code for adding events to the timeline:

MERGE (y:YEAR{year: {y} })
CREATE UNIQUE y-[:HAS_MONTH]->(m:MONTH{month:{m}    })
CREATE UNIQUE m-[:HAS_DAY]->  (d:DAY  {day:  {d}    })     
CREATE UNIQUE d-[:HAS_EVENT]->(e:EVENT{desc: {desc} })
WITH y AS y
MATCH n RETURN n

It seems to work OK but I also need to be able for any event to get next one. I'm not sure how can I establish horizontal (i.e. between months, days, events) links in cypher and If I manage to do it I will need to destroy this links when I insert a new event between two other events. If I don't establish horizontal links the code to get next event in timeline will be rather awkward I think. Or not? What is the best way too implement it?

Kakadu
  • 2,837
  • 19
  • 29
  • congrats, this was the 5000th question tagged with `neo4j` on SO :-) – Stefan Armbruster Jul 19 '14 at 16:55
  • The Page you found is WIP of GraphPatterns. The page in the manual is probably more helpful http://docs.neo4j.org/chunked/milestone/cypher-cookbook-path-tree.html – Michael Hunger Jul 19 '14 at 17:16
  • Usually I link the time-tree horizontally and not the events themselves. So you'd go along the time-tree in sequential order and collect the events beneath. – Michael Hunger Jul 19 '14 at 17:18
  • 1
    If your resolution is only to the day, you can also create the time tree upfront, see my blog post: http://jexp.de/blog/2014/04/importing-forests-into-neo4j/ – Michael Hunger Jul 19 '14 at 17:27

1 Answers1

3

Please take a look at How to filter edges by time stamp in neo4j?

The modeling guideline for time is to use time tree hierarchies for aggregations (Year)->(Month)->(Day), timestamps for ranges, and linked lists for retrieving relative N nodes from any other node (get last 5, get next 5).

Timeline with linked list

Community
  • 1
  • 1
Kenny Bastani
  • 3,268
  • 15
  • 20