Nieralyte
Nieralyte

Reputation: 490

How to express inheritance in (Neo4j) graph database?

If I have an object "player" which is a subcategory of "person", how do I express that in a graph?

Here's an example: https://i.sstatic.net/adzDF.png

Upvotes: 6

Views: 1990

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39925

Use multiple labels:

create ... (:Player:Person {name:'a player'}) ...

In general you assign all the labels up the inheritance tree. This way doing a

match (:Person) return n

would return all the players as well.

Upvotes: 5

Related Questions