关于Arangodb,我知道它有自己的查询语言AQL,据我所知还有一个插件可以使用Gremlin进行图遍历等操作。
在我的一个项目中,我们强烈使用SPARQL,所以: 有没有一种方法可以将SPARQL作为Arangodb的查询语言使用?
最好的问候, 斯特凡
SPARQL是一种专门用于在RDF上工作的语言,因此我们首先需要比较数据存储:
虽然两者都将它们的实体称为“文档”,但它们在许多方面不同。 尽管RDF强制执行模式即使使用自定义数据类型,但ArangoDB是无模式的并且仅支持特定于json的数据类型。 RDF使用从XML命名空间派生的构造来表示这些数据类型。这些命名空间可以嵌套。有一些实现将RDF存储在SQL数据库中。 显然,必须将RDF语法转换为ArangoDB集合(类似于这些RDF / SQL事物)。 Foxx服务层可以提供一个抽象层, 实现这些额外的数据类型; 将一个命名空间映射到一个集合可能会导致许多具有非常少文档的集合。
For example, one way to represent the notion "The sky has the color blue"
in RDF is as the triple: a subject denoting "the sky",
a predicate denoting "has",
and an object denoting "the color blue". Therefore, RDF swaps object
for subject that would be used in the classical notation of an
entity–attribute–value model within object-oriented design;
Entity (sky), attribute (color) and value (blue).
RDF is an abstract model with several serialization formats
(i.e., file formats),
and so the particular way in which a resource or triple is encoded
varies from format to format.
sky -hasColor-> blue
让我们尝试将这个模型映射到ArangoDB:
如果我们将其模拟为类似于RDF,那么命名空间将变成一个集合,每个文档都是该命名空间中的实体:
Collection "Objects":
Document "sky": {_key: "Sky"}
Collection "Colors":
Document "blue": {_key: "blue"}
EdgeCollection "hasColor"
Edge {_from: "Objects/sky", _to: "Colors/blue"}
面向对象的方法是ArangoDB的本地特性(因此使其具有最佳的可扩展性),大致翻译为以下内容:
Collection "Object":
{
_key: "sky"
"hasColor": "blue"
}
hasColor
上)以获得更好的查询性能。虽然第一种方法是将RDF平面映射到ArangoDB中,但会产生很多开销;许多集合包含许多非常简单的文档,难以轻松创建索引。WHERE
子句映射到AQL FILTER
语句中(可能还包括其他集合中的连接)。使用现成的SPARQL javascript解析器可能是不可避免的,但可能不能产生正确的结果。我还尝试过使用一些javascript RDF解析器来解析一些公共可用的RDF数据集并将其导入到ArangoDB中,但似乎这些js解析器还没有准备好进行主流应用。