Multiple graphs using same edge definitions in ArangoDB

白昼怎懂夜的黑 提交于 2019-12-02 03:41:29
mchacki

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!