Multiple graphs using same edge definitions in ArangoDB

前端 未结 1 1756
遥遥无期
遥遥无期 2021-01-25 10:51

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

相关标签:
1条回答
  • 2021-01-25 11:39

    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.

    0 讨论(0)
提交回复
热议问题