简体   繁体   English

使用 ArangoDB 对分散式架构进行建模并同时查询多个源

[英]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.我是 ArangoDB 的新手,想使用它来建模分散式架构。 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.例如,我们的分布式系统中有 3 个节点:节点 1 保存机场数据,节点保存航班数据,节点 3 保存乘客数据。 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? 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). ArangoDB 通过使用“边”链接文档(节点)来工作,边是定义链接方向(到/从)的特殊文档。 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).您的数据库可以有许多命名图,每个图都针对您希望查询的集合进行了定制(就像 RDBMS 一样,减少要查看的内容的数量是提高性能的最简单方法)。

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. AQL 语言允许您在同一个查询中构建复杂的查询,包括多个图形和文档调用。 As always, the main caveats are traversal complexity (see big-O notation ) and memory usage.与往常一样,主要的警告是遍历复杂性(参见big-O 表示法)和内存使用。

These might be a good starting point for basic modeling information, from an ArangoDB perspective:从 ArangoDB 的角度来看,这些可能是基本建模信息的一个很好的起点:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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