Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for storing multi-language property values in Neo4j?

Tags:

I'm storing some nodes in Neo4j graph database and each node has property values that can be localized to various language. Is there any best practice for storing multi-language property values?

like image 450
Stanley Avatar asked Nov 12 '13 08:11

Stanley


People also ask

What can you do to improve the performance of Neo4j?

The size of the available heap memory is an important aspect for the performance of Neo4j. Generally speaking, it is beneficial to configure a large enough heap space to sustain concurrent operations. For many setups, a heap size between 8G and 16G is large enough to run Neo4j reliably.

What are the disadvantages of Neo4j?

Neo4j has some upper bound limit for the graph size and can support tens of billions of nodes, properties, and relationships in a single graph. No security is provided at the data level and there is no data encryption. Security auditing is not available in Neo4j.

Is Neo4j a triple store?

Since the Neo4j graph database is not a triple store, it is not equipped with a SPARQL query engine. However, Neo4j offers Cypher and for many semantic applications it should be possible to translate SPARQL to Cypher queries.

Can you store data as nodes and relationships in Neo4j?

Neo4j is often described as schema optional, meaning that it is not necessary to create indexes and constraints. You can create data — nodes, relationships and properties — without defining a schema up front.


1 Answers

There are couple of ways to model this. Which one is the best, depends on your use case and the way you want to use i18n-ized properties. I'm sketching some examples below assuming n is a node that should have it's productName and color property translated in various languages. Gonna use Cypher-like notation below.

1) storing all translations with the node.

CREATE (n {
productName:'default', color:'default',
productName_en:'engl.prod.name', color_en:'red',
productName_fr:'fr.prod.name', color_fr:'rouge',
})

You apply a naming convention and use <propertyName>_<lang> for the i18n-ized variants. This approach is simplistic and not really graphy.

2) have a subnode per language and entity, indicate the language by relationship type:

CREATE (n {productName:'default', color:'default'}),
(n)-[:TRANSLATION_EN]->({productName: 'engl.prod.name', color:'red'}),
(n)-[:TRANSLATION_FR]->({productName: 'fr.prod.name', color:'rouge'})

So you have 1 additional node and 1 additional rel per language. In Neo4j 2.0 you might additionally indicate the translation nodes with a label indicating the language. By this you can easy extract a list of all text in language xyz.

3) just like 2) but use a generic relationship type TRANSLATION with a property on it indicating the language.

There are couple of more approaches, e.g. you can theoretically use array properties as well. As said, there is no silver bullet, it depends on your use case and requirements.

like image 71
Stefan Armbruster Avatar answered Sep 22 '22 09:09

Stefan Armbruster