سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

That sounds like a UI-level issue, not a database-level one. You're attempting to map the directed relations to a human-friendly name.

For Neo4j, you could put this information into your custom RelationshipType:

public enum MyRelationshipType implements RelationshipType
{
    CHILD("Parent Of", "Child Of");

    public MyRelationshipType(final String forwardString, final String backwardString)
    {
        this.forwardString = forwardString;
        this.backwardString = backwardString;
    }

    private final String backwardString;

    private final String forwardString;

    public String getDisplayString(final boolean forward)
    {
        if (forward)
        {
            return this.forwardString;
        }
        else
        {
            return this.backwardString;
        }
    }
}

In InfoGrid, we have the concept of undirected relationships. For example, "HasMet": if person A has met person B, necessarily B has also met A, and A and B play the same roles in the relationship.

Note that unidirectionality goes beyond naming, it's a core semantic concept that may or may not be understood by a database or modeling language.

Also, in InfoGrid you could define yourself a few TraversalSpecifications and alias them to whatever you like, including basic traversals (go to neighbors related by a particular type of relationship), or multi-step traversals (e.g. go to uncles on your mother's side).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top