首页 > 解决方案 > 关于直接映射转换多对多关系的说明

问题描述

W3C 的 RDB2RDF 标准之一是直接映射。我听说从关系数据库转换多对多关系时出现问题,他们说它失去了语义,我需要更多解释。

标签: sparqlrdfetlowlontology

解决方案


...从关系数据库转换多对多关系时出现问题

我想说直接映射引入了额外的“寄生”语义,将规范化伪影视为一流的对象。

让我们考虑D011-M2MRelations测试用例。

Student
+---------+-----------+----------+
| ID (PK) | FirstName | LastName |
+---------+-----------+----------+
| 10      | Venus     | Williams |
| 11      | Fernando  | Alonso   |
| 12      | David     | Villa    |
+---------+-----------+----------+

Student_Sport
+------------+----------+
| ID_Student | ID_Sport |
+------------+----------+
| 10         | 110      |
| 11         | 111      |
| 11         | 112      |
| 12         | 111      |
+------------+----------+

Sport
+---------+-------------+
| ID (PK) | Description |
+---------+-------------+
| 110     | Tennis      |
| 111     | Football    |
| 112     | Formula1    |
+---------+-------------+

直接映射会生成很多这样的三元组:

<Student_Sport/ID_Student=11;ID_Sport=111> <Student_Sport#ref-ID_Student> <Student/ID=11>.
<Student_Sport/ID_Student=11;ID_Sport=111> <Student_Sport#ref-ID_Sport>  <Sport/ID=111>.
<Student_Sport/ID_Student=11;ID_Sport=112> <Student_Sport#ref-ID_Student> <Student/ID=11>.
<Student_Sport/ID_Student=11;ID_Sport=112> <Student_Sport#ref-ID_Sport>  <Sport/ID=112>.

从头开始建模,你可能会写这样的东西(R2RML 允许实现这一点):

<http://example.com/student/11> <http://example.com/plays> <http://example.com/sport/111>.
<http://example.com/student/11> <http://example.com/plays> <http://example.com/sport/112>.

此外,无法改善对原始表进行非规范化或创建 SQL 视图的结果:如果没有主键,结果可能会更糟

为了改善结果,后续DELETE/INSERT(或CONSTRUCT)似乎是唯一可用的选项。该过程应命名为 ELT 而不是 ETL。也许以下 DM 生成的三元组旨在帮助进行这种转换:

<Student_Sport/ID_Student=11;ID_Sport=111> <Student_Sport#ID_Student> "11"^^xsd:integer.
<Student_Sport/ID_Student=11;ID_Sport=111> <Student_Sport#ID_Sport>  "111"^^xsd:integer.
<Student_Sport/ID_Student=11;ID_Sport=112> <Student_Sport#ID_Student> "11"^^xsd:integer.
<Student_Sport/ID_Student=11;ID_Sport=112> <Student_Sport#ID_Sport>  "112"^^xsd:integer.

...他们说它失去了语义

@JuanSequeda 意味着 DM 不会从关系模式生成 OWL 本体,这种行为不是特定于多对多关系的。


另请参阅第 14 期的链接。


推荐阅读