问题
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