简体   繁体   中英

Edge Collection vs. Graph

There's one thing I don't get in ArangoDB:

What's the difference between an edge collection and a graph? In which cases should I choose which?

Graphs in ArangoDB are built on top of documents and edges.

Edge collections have automatic indexes on _from and _to , allowing efficient retrieval of any connected documents. Because data are still stored in regular (document and edge) collections, you can use these collections in non-graph queries, too.

Graphs add some functionality (ie query methods, traversals) on top of the data. You can have multiple of them in ArangoDB. Think of a "graph" being a means of grouping for parts or all of your data, and making them accessible in queries.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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