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

查看:32
本文介绍了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 强制实施模式即使使用自定义数据类型,但 ArangoDB 是无模式的,仅支持 json 特定数据类型.对于这些数据类型,RDF 使用从 XML 命名空间派生的构造.这些命名空间可以嵌套.有在 SQL 数据库中存储 RDF 的实现.显然,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.

正如维基百科在其关于资源描述框架的文章中所描述的:

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.

虽然您可以将一组基本的 SPARQL WHERE - 子句映射到 AQL FILTER - Foxx 服务中的语句(并且可能加入其他集合)使用现成的 SPARQL javascript 解析器 可能是不可避免的,但可能不会产生正确的结果.

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 + SPARQLArangoDB + 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 文档更详细地讨论了如何将 RDF 数据映射成图

The ArangoDB Documentation discusses in deeper detail how to map RDF data into graphs

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

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