0

请求帮助表示对空白节点的域限制。 图 1:使用空白节点建模多对多关系。使用空白节点建模多对多(关系)表

业务规则:一次注册将一名学生映射到一个部门。

我的尝试:

∃hasStudent.⊤ ≡ ∃hasSection.⊤ ≡ ∃grade_code.⊤ 

i.e. "the set of individuals that have some value for the role 'hasStudent' is the same set of individuals that have some value for the role 'hasSection' ...e.t.c."

我在这里假设等价而不是包含,因为包含将是双向的。

进一步限制:

∃hasStudent.⊤ ≡ ∃hasSection.⊤ ≡ ∃grade_code.⊤ ≡ =1hasStudent.⊤ ≡ =1hasSection.⊤ ≡ =1grade_code.⊤

i.e. "the set of individuals that have values for the roles 'hasStudent', 'hasSection' and 'grade_code', have one and only one value for them."

对正确表示图 1 中对象属性的域限制的帮助或评论将不胜感激。

谢谢!!

4

2 回答 2

2

OWL 的开放世界假设将阻止您找到“对角色 'hasStudent'、'hasSection' 和 'grade_code' 具有值的个人集合,它们只有一个值。”

但是,使用 SPARQL,您可以创建一个 ASK 查询来满足您的要求:

ASK {
   SELECT (count(?student) AS ?stcount) (count(?section) AS ?secount) (count(?course) AS ?ccount)
   WHERE {
      ?indiv :hasStudent ?student .
      ?indiv :hasSection ?section .
      ?indiv :grade_course ?course .
   } GROUP BY ?student ?section ?course
   HAVING (stcount = 1 && ?secount = 1 && ?ccount = 1)
}

语法上有点尴尬,因为聚合需要通过 SELECT 语句计算。如果“约束”(参见 HAVING 子句)全部为真,则 ASK 将返回真,否则返回假。

为了将来参考,W3C 的SHACL(RDF 形状约束语言)工作旨在支持这些类型的约束违反问题,而这些问题是 OWL 无法回答的。

于 2016-02-14T21:04:39.630 回答
1

如果我正确理解您的意图,您希望这些限制适用于这些属性的任何使用,而不是仅适用于特定类。

在此假设下,您可以通过声明属性功能并将其域设置为C. 在函数式语法中:

Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)

Ontology(
Declaration(Class(<urn:test:C>))
Declaration(ObjectProperty(<urn:test:hasSection>))
Declaration(ObjectProperty(<urn:test:hasStudent>))
Declaration(DataProperty(<urn:test:grade_code>))

FunctionalObjectProperty(<urn:test:hasSection>)
ObjectPropertyDomain(<urn:test:hasSection> <urn:test:C>)

FunctionalObjectProperty(<urn:test:hasStudent>)
ObjectPropertyDomain(<urn:test:hasStudent> <urn:test:C>)

FunctionalDataProperty(<urn:test:grade_code>)
DataPropertyDomain(<urn:test:grade_code> <urn:test:C>)

SubClassOf(<urn:test:C> ObjectIntersectionOf(ObjectSomeValuesFrom(<urn:test:hasSection> owl:Thing) ObjectSomeValuesFrom(<urn:test:hasStudent> owl:Thing) DataSomeValuesFrom(<urn:test:grade_code> rdfs:Literal)))
)
于 2016-02-10T08:00:24.893 回答