ArangoDB 边缘集合与图形

9jyewag0  于 2022-12-09  发布在  Go
关注(0)|答案(2)|浏览(154)

在ArangoDB中有一件事我不明白:
边集合和图有什么区别?在哪些情况下我应该选择哪一种?

qmelpv7a

qmelpv7a1#

ArangoDB中的图形是在文档和边缘之上构建的。
边缘集合在_from_to上有自动索引,允许有效检索任何连接的文档。因为数据仍然存储在常规(文档和边缘)集合中,所以您也可以在非图形查询中使用这些集合。
图表在数据的顶部添加了一些功能(例如查询方法、遍历)。在ArangoDB中可以有多个图表。可以将“图表”看作是对部分或全部数据进行分组的一种方法,并使它们在查询中可访问。

p5cysglq

p5cysglq2#

This is an edge:

{
  "_id": "edges/328701573688",
  "_from": "nodes/150194180348",
  "_to": "nodes/328668871224",
  "_rev": "3680146597",
  "_key": "328701573688",
  "type": "includes"
}

This is a document:

{
  "_id": "nodes/328668871224",
  "_rev": "3610088613",
  "_key": "328668871224",
  "name": "Gold-edged Gem",
  "type": "species"
}

As you can see there is no fundamental difference. They are both documents. Edge collections are only useful for when you using Arango for it's graph database capabilities.
As I understand it, the point setting the type of the collection to "edge" tells Arango that it should be ensuring that all documents stored in there minimally have _to and _from attributes so that the document can serve its function as a connector between two other documents.
Once you have a document collection whose documents are connected by a bunch of edge documents in an edge collection... now you have a graph.

相关问题