在 RDF 中表示 grid/matrix 的最简单方法是什么?

What's the simplest way to represent a grid/matrix in RDF?

我不确定如何表达这个问题,所以如果有更好的术语或现有答案,请指点我!这是我第一次使用 RDF 设计任何东西。

我正在制作一个小型个人知识库来跟踪实验室中的项目,但不确定如何最好地编码 2D 位置。到目前为止,我想到的唯一想法是让 everything 成为一个容器。例如,如果我有一个 96 孔板,它将是一个有 12 列和 8 行的大容器,每个容器都是带有孔的容器,每个孔都是一个容器,其中装有我感兴趣的东西跟踪。

看起来足够灵活,可以处理很多实际情况,但查询起来有点麻烦。要在板 p0001 的孔 B7 中获得应变,它类似于:"describe strain s which is in well w, which is in row r and also in column c, where r and c are in plate p, and p is labeled p0001, and c is labeled 7 and r is labeled B"(请原谅可怕的伪 SPARQL)

有没有更简单的方法?我想这会出现在很多涉及库存的业务环境中,所以人们可能已经明白了。

我不确定的另一件事是对索引本身进行编码。我应该将它们标记为文字吗?

编辑:盘子看起来 like this

这可能过于宽泛,无法给出正确的答案,但我认为有一些选择。我将从那些实际上与编码网格有关的内容开始,但以我认为实际上最合适的内容结束。

使用所有数组索引对结构进行编码

RDF 中的容器,除了列表和与其类似的结构外,没有有序存储。 RDF 只是一个 set 三元组。这意味着如果你想维护任何类型的基于索引的引用,那么你需要直接对其进行编码。这并不难。假设我们有一个像

这样的数组
[[a, b, c],
 [d, e, f]]

然后我们可以很容易地做这样的事情:

@prefix : <urn:ex:>

:array :hasElement [ :value :a ; :row 0 ; :column 0 ] ,
                   [ :value :b ; :row 0 ; :column 1 ] ,
                   [ :value :c ; :row 0 ; :column 2 ] ,
                   [ :value :d ; :row 1 ; :column 0 ] ,
                   [ :value :e ; :row 1 ; :column 1 ] ,
                   [ :value :f ; :row 1 ; :column 2 ] .

然后您可以轻松地使用 SPARQL 查询,例如:

prefix : <urn:ex:>

select ?value where {
  :array :hasElement [ :value ?value ; :row 1 ; :column 2 ]
}

使用隐式索引编码结构

您还可以使用像 RDF 列表(单向链表)这样的结构并按位置查找元素,就像您可以计算元素在列表中的位置一样。我在对 Is it possible to get the position of an element in an RDF Collection in SPARQL? 的回答中描述了这一点,但是,这可能效率很低,我怀疑你是否想这样做。

使用底层语义编码结构

但是,如果您有 table 或数据网格,行和列实际上可能 意味着 某些东西;它可能不仅仅是一个价值网格。在那种情况下,您可能可以用语义上更有意义的方式来表示数据。例如,如果您有一个 table,例如:

Name    Age    Height
---------------------
John     45        78
Mary     30        60
Susan    25        59

然后 "conventional" 表示这一点的方法是,每一行都有一个单独的个体,每一行都有对应于每一列的属性:

:row1 a :Row ; :name "John"  ; :age 45 ; :height 78 .
:row2 a :Row ; :name "Mary"  ; :age 30 ; :height 60 .
:row3 a :Row ; :name "Susan" ; :age 25 ; :height 59 .

差不多Defining N-ary Relations on the Semantic Web, if you treat each row as an instance of a relation. A Direct Mapping of Relational Data to RDF中给出的方法也很相关。

针对您的用例

由于您的用例(我不得不查找 "well plate" 是什么),看来您实际上可能需要这些数字索引,因此第一种和第三种方法的一些组合可能是您想要的.

Seems flexible enough to handle lots of real situations, but querying it is kind of cumbersome. To get the strain in well B7 of plate p0001, it would be something like: "describe strain s which is in well w, which is in row r and also in column c, where r and c are in plate p, and p is labeled p0001, and c is labeled 7 and r is labeled B" (Excuse the horrible pseudo-SPARQL)

我不认为这有那么麻烦。根据您标记列和行的方式,它可能类似于:

select ?strain where {
  ?plate rdfs:label "p0001" ;
         :hasWell [ :row "7" ;             #-- or :row/rdfs:label "7", or ...
                    :col "B" ;             #-- or :col/rdfs:label "B", or ...
                    :contains ?strain ] .
}