I have an existing live neo4j db with relationships like this...
User-[:Owner]->Item
User
contains the usual properties; name
, email
etc.Owner
relationship has created_on
propertyItem
has a bunch of properties about the item; title
, description
etc.
I want to add in a geo-location
property for the Item
. This will be a latitude
and longitude
of where the user created the item.
A JSON api is serving up this data to our clients. The API will merge some of the data, so an Item
object in the api will have a nested User
object as a property of it...
"item": {
"title":"my item",
"user":{
"name":"smith"
}
}
And I was initially thinking the location would follow suit...
"item": {
"title":"my item",
"user":{
"name":"smith"
},
"geo_position":{
"latitude":"10.123456789",
"longitude":"10.123456789"
}
}
As we cant nest data in Neo, was wondering how to store this data...
geo_position
property of the Item
? Owner.latitude
? Location
`User-[:owns]->Mite<-[:created_at]-Location?Item
so not nested, item.latitude
? 1 - I assume we cant query.
2 - doesn't feel like the right place.
3 - its extremely unlikely 2 Items
will have the same location as lat long is very precise, so almost No Items
will share this node, so is it really a node?
So is 4 really the way to do it, and just not nest them ?
m
property* Stores the key/value properties from your database label* Stores index related label data from your graph Since Neo4j is a schema-less database, we use fixed record lengths to persist data and follow offsets in these files to know how to fetch data to answer queries.
Considering alternatives to Neo4j? See what Cloud Database Management Systems Neo4j users also considered in their purchasing decision. When evaluating different solutions, potential buyers compare competencies in categories such as evaluation and contracting, integration and deployment, service and support, and specific product capabilities.
* Neo4j by itself is the leading graph database. If what you need is a pure graph database it is a pretty good option. * ArangoDB and OrientDB are the next ones on the list. These are multimodel graph databases that can be useful if you need Graph + JSON documents + SQL. Don't focus too much on benchmarks comparing them performance to Neo4j.
Using BLOB data in Neo4j is one of the very few real anti-patterns for graph databases, in my opinion. If you have to deal with BLOB data, choose an appropriate store for that use case and use Neo4j to store the URL that points you to the binary data.
You own analysis is basically correct. I would go with number 4.
Here is more about why number 2 is not a good idea. Logically: the location of an item belongs in that item's node, not in a particular relationship to it. Practically: if the object changed ownership you should not have to copy its location to a new relationship, and querying for an item's location should be as quick and simple as just getting its node.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With