1
votes

I am evaluating ArangoDB and trying to create multiple graphs that might contain same node collections and same edge collections - even though each graph might contain different physical documents and edges.

However when trying to create a graph that would use an edge collection that is already used in another graph I am getting "[1921] ... edge collection already used in edge def" error.

Why can't graphs reuse existing relationships when it is possible for graphs to share same document collections and documents?

To work around this issue I have to create a separate uniquely-named edge definition for each new graph and manage them separately.

E.g. I have generic relationship called "next". This relationship (edge) could be used in many graphs as it simply depicts a generic link between nodes. However every time I create a new graph I also need to create new edge definition called "[graph-name]-next" instead of just reusing exiting "next" edge definition - if I try to do so I get the [1921] error.

Edit: mchacki in a response below indicated it should be possible to use one relationship in multiple graphs - so the question is: If it is possible how to do it without getting the 1921 error?

1

1 Answers

3
votes

The idea of the graph-module and the edge definitions is the following: You define relations once, e.g.:

isFriend: Person -> Person
owns: Person -> Item

creating two edge collections (isFriend and owns) and two document collections (Person and Item). Now you can use the exact same relation in as many graphs as you like. Say you have a social graph using only the isFriend relation. But you also have an eCommerce graph using the owns relation and the isFriend relation at the same time. Now eCommerce and social share isFriend relation which is totally supported by ArangoDB.

What is not supported is an edge definition say generic which is used in one graph as:

generic: Person -> Person

and in another one as

generic: Item -> Item

The problem here is, that there would be a collection called generic and both graphs access it. In a query the first graph now "knows" that there can only be edges Person -> Person in this collection where the second one "knows" that there are only Item -> Item relations. And in both graphs the relations of the other graph do not make any sense but are possibly catched by queries.

So this means if you want to reuse the stored edges in addition to the stored documents in several graphs you have to create a rather generic edge definition for these cases and handle unexpected hits yourself. For each edge definition you can add arbitrary many vertex collections in from and to location and even modify them during runtime.

So in your case every time you create a new graph you first modify the relation using one of the existing graphs (will be propagated) to contain the information about added collections and than reuse this relation in your new graph.