在 ArangoDB 中使用相同边定义的多个图 [英] Multiple graphs using same edge definitions in ArangoDB

查看:34
本文介绍了在 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"的通用关系.这种关系(边)可以用在许多图中,因为它只是描述了节点之间的通用链接.然而,每次我创建一个新图时,我还需要创建一个名为 "[graph-name]-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 和 owns)和两个文档集合(Person 和 Item).现在,您可以在任意数量的图表中使用完全相同的关系.假设您有一个仅使用 isFriend 关系的 social 图.但是您还有一个同时使用 owns 关系和 isFriend 关系的 eCommerce 图.现在eCommercesocial 共享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.

所以这意味着如果你想在多个图表中重用存储的边和存储的文档,你必须为这些情况创建一个相当通用的边定义并自己处理意外的命中.对于每个边定义,您可以在 fromto 位置添加任意多个顶点集合,甚至可以在运行时修改它们.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆