ArangoDB的Sparql接口 [英] Sparql-interface for ArangoDB

查看:119
本文介绍了ArangoDB的Sparql接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于arangodb,我知道它自己的查询语言AQL,据我所知,还有一个附加组件,允许使用Gremlin进行图遍历等.

for arangodb, I know its own query language AQL, and as far as I can see there is also an add-on which allows to use Gremlin for graph traversals etc.

在我的一个项目中,我们强烈使用SPARQL,因此: 有没有办法将SPARQL用作arangodb的查询语言?

In one of my projects, we strongly use SPARQL, so: Is there a way to use SPARQL as query language for arangodb?

最好的问候, 斯蒂芬

推荐答案

SPARQL和RDF如何与AQL和ArangoDB相关?

SPARLQ是一种专门用于RDF之上的语言,因此我们首先需要比较数据存储:

How can SPARQL and RDF relate to AQL and ArangoDB?

SPARLQ is a language tailored to work on top of RDF, therefore we first need to compare the datastores:

尽管两者都将其实体称为文档",但它们在许多方面都存在差异. 尽管RDF即使使用自定义数据类型也可以强制实施> schemata ,但ArangoDB是无方案的,仅支持json特定的数据类型. 对于这些数据类型,RDF使用从XML命名空间派生的构造.这些名称空间可能是嵌套的.有一些将RDF存储在SQL数据库中的实现. 显然,RDF语法必须转换为ArangoDB集合(类似于这些RDF/SQL事物). Foxx服务层可以提供抽象 实现这些额外的数据类型;将一个名称空间映射到一个集合可能会导致许多集合中的文档很少.

While both refer to their entities as 'document' they're different in many ways. While RDF enforces schemata even with custom data types, ArangoDB is schemaless and only supports json specific data types. RDF uses a construct derived from XML-namespaces for these datatypes. These namespaces may be nested. There are implementations storing RDFs in SQL databases. Obviously the RDF grammer has to be translated into ArangoDB collections (similar to these RDF/SQL things). A Foxx service layer could deliver an abstraction that implements these additional datatypes; mapping one namespace to one collection will probably result in many collections with very few documents.

如Wikipedia在其关于资源描述框架的文章中所描述的那样:

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.

尽管RDF具有三元模型,但ArangoDB宁愿使用面向对象的设计.

While RDF has their triple model, ArangoDB rather uses the object oriented design.

所以我们在RDF中有这个源模型:

So we have this source model in RDF:

sky -hasColor-> blue

让我们尝试将此模型映射到ArangoDB:

Lets try to map this model to ArangoDB:

如果我们模仿它与RDF'相似',则名称空间将成为一个集合,每个文档都是该名称空间中的一个实体:

If we mimic it being 'similar' to RDF, A namespace will become a collection, each document is an entity in that namespace:

Collection "Objects":
Document "sky": {_key: "Sky"}

Collection "Colors":
Document "blue": {_key: "blue"}

EdgeCollection "hasColor"
Edge {_from: "Objects/sky", _to: "Colors/blue"}

面向对象的方法作为ArangoDB的本机(因此使其可以最佳扩展)将转化为以下内容:

The object oriented aproach as its native to ArangoDB (and thus allows it to scale best) would translate into something like this:

Collection "Object":
{
  _key: "sky"
  "hasColor": "blue"
}

第二种方法利用的是,您已经对数据有了清晰的了解,而不是对数据进行元数据查看, 您可以指定索引(即在hasColor上)以提高查询性能.第一个方法是将RDF平面映射到 ArangoDB将产生大量开销;许多馆藏的文档非常简单,没有索引很容易.

The second aproach utilizes that instead of having a meta-view to your data you already have a pretty sharp picture of your data, You can specify indices (i.e. on hasColor) for better query performance. While the first aproach is a flat mapping of RDF to ArangoDB will produce much overhead; many collections with many very simple documents, no indices easily possible.

尽管您可以将一组基本的SPARQLs WHERE-子句映射到AQL FILTER-Foxx服务中的语句(并可能加入其他集合)

While you may map a basic set of SPARQLs WHERE - clauses into AQL FILTER - statements in a Foxx-service (and maybe joins into other collections) using a readily available SPARQL javascript parser may be ineviteable, but may not produce proper results.

我还尝试了一些javascript RDF解析器 解析一些公开可用的RDF数据集,以将其导入ArangoDB,但似乎这些js解析器尚未准备就绪.

I also experimented with some of the javascript RDF parsers to parse some of the publicaly available RDF datasets to import them into ArangoDB, but it seems these js parsers are not yet ready for prime time.

虽然 RDF + SPARQL ArangoDB + AQL 之间存在重叠,但是也有很多空白需要填补. 尽管我们会支持其他人填补这些空白,但我们目前无法专注于此. 为了提供ArangoDB的令人满意的体验,最终将依靠RDF模式的手动转换,然后很可能无法通过自动转换的SPARQL来查询.

While there are overlappings between RDF + SPARQL and ArangoDB + AQL, there are also significant gaps that would have to be filled. While we would support others filling these gaps, we currently can't focus on that. To deliver a satisfying experience with ArangoDB one would in the end lean on manual translation of the RDF schema, which then most probably can't be queried by automatically translated SPARQL.

可以采取的步骤:

  • 查找/修复RDF解析器
  • 找到一种比上述草拟的方法更聪明的方法,以自动将RDF模式转换为可通过ArangoDB很好地扩展的收集模式
  • 使用解析器来解析SPARQL并将其应用于上述架构,并从中构造AQL.

这篇关于ArangoDB的Sparql接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆