Search code examples
nosqlneo4jgraph-databasesorientdb

Directional Relationships with different name for each direction


In GraphDB platforms (Neo4j, OrientDB, FlockDB, HyperGraphDB...) it is possible to define relationships between nodes.

I need to define directional relationships, such that the relation has different names depending on its direction.

For example:

Parent(A,B) := Sibling(B,A).

Then, I want to traverse or query a graph using both terms and directions.

Of course, I don't want to define two relationships, but only one.

Sometimes I even want to use a non-directional name, for example:

Call(A,B) := Answer(B,A);
TalkWith(A,B) := Call(A,B) || Call(B,A)

And use a directional or indirectional traversals / queries

For example, I may want to ask:

Get any X that TalkWith(A,X))

or

Get any X that Call(A,X))

or

Get any X that Answer(A,X))

Which existing GraphDB platforms support it?


Solution

  • In Gremlin (http://gremlin.tinkerpop.com), you can create abstract/implicit/inferred relationships from what is explicit in the data. As such, you can define inferences in this manner.

    https://github.com/tinkerpop/gremlin/wiki/User-Defined-Steps

    Gremlin works over TinkerGraph, Neo4j, OrientDB, DEX, and RDF Sail Stores.

    Hope that helps, Marko.