How to include time into graph mapping (Neo4j)

我只是一个虾纸丫 提交于 2019-12-11 02:54:01

问题


I'm building a simple system for profiling people. I'm currently using neo4j to build simple relations between users. For example I have simple tuple

mike met sara

But how could I integrate time? For example

mike met sara 2 days ago OR mike will meet sara in 3 days

The main reason is because the relation can happen multiple times at different times. My goal is to be able to answer questions:

  • has mike met sara in last week?
  • are mike and sara dating (dating = they meet at least 5 times a week)?
  • what is the longest period mike and sara did not meet?
  • does mike have personal problems? (we can introduce mike met bill where sara & bill both have personality attribute "helping people". So we can presume if mike didn't met with sara or bill in last year but has X meeting in last week, something is wrong with him)

What is the best way to get these answers? Is Neo4j the right way to go?


回答1:


I think what you want to model is events in time. Those events (e.g. Meeting) are nodes that are connected to the participants, places, additional information etc.

Then you can choose to link the events in a ordered list that represents their chronological order, i.e. a timeline.

For fast access of sub-parts of the timeline you could, create a time-tree (year->month->day[->hour]->event)

See this for a concrete example: http://docs.neo4j.org/chunked/milestone/cypher-cookbook-path-tree.html



来源:https://stackoverflow.com/questions/22274911/how-to-include-time-into-graph-mapping-neo4j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!