在ArangoDB中使用相同边定义的多个图 [英] Multiple graphs using same edge definitions in ArangoDB
问题描述
我正在评估ArangoDB,并尝试创建可能包含相同节点集合和相同边集合的多个图,即使每个图可能包含不同的物理文档和边.
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.
但是,当尝试创建将使用已在另一张图中使用的边集合的图时,出现" [1921] ...边定义中已使用边集合"错误.
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.
为什么图形可以共享相同的文档集合和文档,为什么图形不能重用现有关系?
要变通解决此问题,我必须为每个新图创建一个单独的唯一命名的边缘定义,并分别进行管理.
To work around this issue I have to create a separate uniquely-named edge definition for each new graph and manage them separately.
例如,我有一个通用关系,称为" next ".这种关系(边缘)可用于许多图中,因为它仅描绘了节点之间的通用链接.但是,每次创建新图形时,我还需要创建一个名为" [图形名称] -next" 的新边定义,而不是仅重复使用退出的" next" "边缘定义-如果尝试这样做,则会出现[1921]错误.
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.
mchacki在下面的回复中指出,应该可以在多个图形中使用一种关系-因此问题是:如果有可能在没有得到1921年的情况下如何做到这一点错误?
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?
推荐答案
图形模块和边定义的概念如下: 您只需定义一次关系,例如:
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
创建两个边缘集合(isFriend和拥有者)和两个文档集合(人和物品).
现在,您可以在任意数量的图形中使用完全相同的关系.
假设您有一个仅使用isFriend
关系的social
图.
但是,您同时具有使用owns
关系和isFriend
关系的eCommerce
图.
现在eCommerce
和social
共享isFriend
关系,而ArangoDB完全支持该关系.
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.
不支持的是边定义,例如generic
,在一张图中用作:
What is not supported is an edge definition say generic
which is used in one graph as:
generic: Person -> Person
,另外一个是
generic: Item -> Item
这里的问题是,会有一个名为generic
的集合,并且两个图都对其进行访问.
在查询中,第一个图现在知道"该集合中只能有边Person
-> Person
,而第二个图知道"只有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.
因此,这意味着,除了要在多个图形中重复使用存储的文档外,还需要重用存储的文档边缘,您必须为这些情况创建一个相当通用的文档边缘定义,并自己处理意外的命中事件.
对于每个边缘定义,您可以在from
和to
位置中添加任意多个顶点集合,甚至可以在运行时对其进行修改.
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.
这篇关于在ArangoDB中使用相同边定义的多个图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!