简体   繁体   English

在ArangoDB中使用相同边缘定义的多个图形

[英]Multiple graphs using same edge definitions in 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. 我正在评估ArangoDB并尝试创建可能包含相同节点集合和相同边集合的多个图形 - 即使每个图形可能包含不同的物理文档和边缘。

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. 但是,当尝试创建一个将使用已在另一个图形中使用的边集合的图形时,我得到“ [1921] ...已在边缘def中使用的边集合 ”错误。

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. 要解决此问题,我必须为每个新图创建一个单独的唯一命名边定义,并单独管理它们。

Eg 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. 但是每次我创建一个新图形时,我还需要创建一个名为[graph-name] -next”的新边缘定义,而不是仅仅重用退出的“ 下一个 ”边缘定义 - 如果我尝试这样做,我会得到[1921]错误。

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? 编辑: mchacki在下面的回复中指出应该可以在多个图中使用一个关系 - 所以问题是: 如果有可能怎么做而不会得到1921错误?

The idea of the graph-module and the edge definitions is the following: You define relations once, eg: 图模块和边缘定义的概念如下:您定义一次关系,例如:

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

creating two edge collections (isFriend and owns) and two document collections (Person and Item). 创建两个边集(isFriend和owns)和两个文档集(Person和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. 假设您只使用isFriend关系的social图。 But you also have an eCommerce graph using the owns relation and the isFriend relation at the same time. 但是你也有一个使用owns关系和isFriend关系的eCommerce图表。 Now eCommerce and social share isFriend relation which is totally supported by ArangoDB. 现在eCommercesocial分享是isFriend关系,完全由ArangoDB支持。

What is not supported is an edge definition say generic which is used in one graph as: 不支持的是边缘定义,表示在一个图形中使用的generic

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. 这里的问题是,会有一个名为generic的集合,两个图都可以访问它。 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. 在查询中,第一个图形现在“知道”在此集合中只能存在边 - Person - > Person ,其中第二个“知道”只有Item - > Item关系。 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. 对于每个边缘定义,您可以在fromto location中添加任意多个顶点集合,甚至可以在运行时修改它们。

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. 因此,在您的情况下,每次创建新图时,首先使用现有图之一(将进行传播)修改关系,以包含有关已添加集合的信息,并在新图中重用此关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM