NarenSuri
NarenSuri

Reputation: 51

how to store location and time stamp data using Neo4j

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.

Upvotes: 2

Views: 772

Answers (1)

Supamiu
Supamiu

Reputation: 8731

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)

Example graph description

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.

Upvotes: 2

Related Questions