how to store location and time stamp data using Neo4j

无人久伴 提交于 2020-01-03 02:53:12

问题


how to store location and time stamp data generated by the buses every 2 minutes on different routes using Neo4j.

Route 1 :
A-> B-> C-> D-> C-> B-> A [route created in neo4j] how to achieve below time-stamp storing?
8:01 8:10 8:25 9:10 9:xx xxx xxx
x:x xx:xx xx:xx xx:x x:x X:X

Route 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

In rdbms, i store the time with each bustop as column id. How to do this neo4j. Stuck with my college project, any help would be appreciated.


回答1:


To create a good data model, you have to wonder what you will be looking for in your datas.

Here, you will be looking for a timestamp (or at least an HH:mm data) to know when a bus will reach a stop.

So, you will need two nodes:

: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)

And one relationship:

:REACHED
    date: timestamp

Example model (PNG extracted from neo4j web interface)

So, when a bus reaches a stop, you simply have to create one relation between your bus node and the stop node he just reached, using timestamp() neo4j method to generate the exact timestamp of the creation of your relation.

Then, to match every stop of a bus, you can extract the timestamp value from REACHED relationship.



来源:https://stackoverflow.com/questions/33712447/how-to-store-location-and-time-stamp-data-using-neo4j

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