简体   繁体   中英

Model decentralized architecture using ArangoDB and querying multiple sources at once

I'm new to ArangoDB and was wondering to model a decentralized architecture using it. As it says in the documentation it supports multiple classes of DBs. I want to make a data model that will have multiple graphs as a small distributed system for let's say simulation purposes . Now once I have distributed system I want to query all these sources as one. For instance, we have 3 nodes in our distributed system: node 1 holds data for airports, node holds data for flights, and node 3 holds data for passengers. Now my question is can I query all three nodes by writing a single query or maybe multiple queries what I want is to hit multiple nodes from a single interface. Is it possible with ArangoDB?

  • If I'm not clear drop your query

...can I query all three nodes by writing a single query...

The short answer is "yes", but with a big "it depends on your data model" asterisk. The shift from relational to graph can be strange, and it's all too easy to build a data set that doesn't scale well.

ArangoDB works by linking documents (nodes) using "edges", which are special documents that define link direction (to/from). Edge collections can be used to run queries ( anonymous graphs ) or can be "grouped" into more well-defined, elaborate graph definitions ( named graphs ). Your database can have many named graphs, each tailored to fit the collections you wish to query (as is the case with RDBMS, reducing the number of things to look at is the easiest way to increase performance).

Generally, you would make collections of things by a high-level type, and group membership can be defined either by attribute(s) on documents/edges or simply through edge connections. The best speed will be achieved by keeping your queries in-memory, which means staying away from filtering on non-indexed attributes.

From your question, it sounds like you want two collections ("airports" and "passengers"), along with an edge collection of "flights" (maybe a graph of "airport -> passenger -> airport"). This example demonstrates a simple actors/movies dataset that is designed to be graph-friendly, but there are many airport/trip graph samples on the interwebs.

The AQL language allows you to build complex queries, including multiple graphs and document calls, in the same query. As always, the main caveats are traversal complexity (see big-O notation ) and memory usage.

These might be a good starting point for basic modeling information, from an ArangoDB perspective:

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