Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with type hierarchies in Neo4j?

Is there some way to model type hierarchies in Neo4j? If for example I want to build a class hierarchy of cars, I might have a base type of "Car" and then have sub classes that extend that, like "SportCar", etc.

I'd like to be able to create instances of "SportCar", but run a query to get all "Car"s. Is this possible? If so what is the technique?

I think what I'm trying to do is create a "label hierarchy" - but I just don't think that's supported in neo4j.

like image 704
Paul Fryer Avatar asked Jul 21 '14 19:07

Paul Fryer


People also ask

What are the weaknesses of Neo4j?

Additionally, Neo4j has scalability weaknesses related to scaling writes, hence if your application is expected to have very large write throughputs, then Neo4j is not for you.

Does Neo4j support Gql?

Graph Query Language (GQL) Is Now a Global Standards Project. Platform Overview → Neo4j graph technology products help the world make sense of data.

Is Neo4j still relevant?

The World's Leading Organizations Rely on Neo4j. With more than 950 enterprise customers, Neo4j is the world's leading provider of scalable graph technology, enabling connected data applications for more than 75% of the Fortune 100.

How can I improve my Neo4j performance?

Heap Sizing 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.


1 Answers

There are at least two ways to do that:

1) Use multiple lables for each object

CREATE(BMW325d:Car:PassengerCar:DieselCar)
CREATE(Porsche911:Car:SportsCar:...)

2) Create an Ontology

The second way of modeling a class hierarchy is using ontologies. Although Neo4j models data as a property graph and ontologies are more suitible for RDF Triple Stores there are ways to use them.

You can create the ontology using Protégé (Open Source). Then you save the Ontology in an .owl-File and upload it to Neo4j using this Plugin. Afterwords you assert your nodes in Neo4j to the Metagraph created in Protégé. A more detailed description is described here.

more on this topic...

For your purposes an RDF Triple Store is an interesting option, escpecially if you want to add semantics to your data like to use inferences and inheritance. I recommend to take a closer look on RDF Triple Stores, which are also graphs - but they store data in triples (subject - predicate - object) instead of nodes and relations. Top Braid Composer is an "easy-to-learn"-tool to get started with them.

Although, I hope that the gap between Property Graphs and RDF triple stores will get smaller soon at the moment it is a tradeoff. SO you should carefully set your requirements on the database before choosing one of them.

Hope this helps.

like image 170
Grapheneer Avatar answered Sep 20 '22 18:09

Grapheneer