如何使用Neo4j存储位置和时间戳数据

时间:2015-11-14 19:31:26

标签: neo4j spring-data-neo4j

如何使用Neo4j在不同路线上每隔2分钟存储公交车产生的位置和时间戳数据。

路线1:
A-> B-> C-> D-> C-> B->一个[在neo4j中创建的路由]如何实现下面的时间戳存储?
8:01 8:10 8:25 9:10 9:xx xxx xxx
x:x xx:xx xx:xx xx:x x:x X:X

路线2:
G-> G-> H-> I-> J-> K-> L
10:01 10:10 10:25 11:10 12:xx xxx
x:x xx:xx xx:xx xx:x x:x X:X

在rdbms中,我将每个bustop的时间存储为列id。怎么做这个neo4j。坚持我的大学项目,任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

要创建一个好的数据模型,您必须想知道您将在数据中寻找什么。

在这里,您将寻找一个时间戳(或至少一个HH:mm数据)来了解公共汽车何时停止。

因此,您需要两个节点:

:Bus
    id: integer (Unique id for the bus)
    route: integer (I suppose you have bus numbers)

:Stop
    id: integer (unique id for the stop)
    location: string (I don't know if you have the GPS coordinates, but you can store them using a string)
    name: string (your stops are having a name I guess)

和一个关系:

:REACHED
    date: timestamp

示例模型(从neo4j web界面提取的PNG)

Example graph description

因此,当总线到达停靠点时,您只需在总线节点和刚到达的停止节点之间创建一个关系,使用timestamp() neo4j方法生成关系创建的确切时间戳

然后,为了匹配总线的每个停靠点,您可以从REACHED关系中提取时间戳值。

相关问题