Reputation: 1084
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?
Upvotes: 4
Views: 1168
Reputation: 24793
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.
Upvotes: 2
Reputation: 9097
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 (i.e. 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.
Upvotes: 7