SPAQRL 创建排除查询

问题描述

我有这种结构


<ontology:Louvre>  
<rdf:type ontology:Museum/>
<ontology:preserves rdf:Gioconda/>
<ontology:locatedIn rdf:Paris/>
<ontology:name>Louvre</ontology:name>

<ontology:Gioconda>
<rdf:type ontology:Artwork/>
<ontology:preserved rdf:Louvre/>
<ontology:author rdf:Leonardo/>
<nomeOpera>Gioconda</nomeOpera>

<rdf:Leonardo_Da_Vinci>
<rdf:type ontology:Painter"/>
<ontology:paint ontology:Gioconda"/>
<ontology:paint ontology:Ultima_cena"/>
<name>Leonardo Da Vinci</name>

...(other museum,artist and artwork)
I use "ontology" to indicate my prefix

有没有可能找回博物馆的独家艺术家?

解决方法

我找到了解决方案。 这是我正在寻找的查询

SELECT DISTINCT * WHERE {
   ?museum ontology:preserves ?artwork .
   ?museum ontology:name "Louvre" .
   ?artwork ontology:author ?author.
    FILTER NOT EXISTS{
        ?museum2 ontology:preserves ?artwork2 .
        ?artwork2 ontology:author ?author .
        FILTER (?museum2 != ?museum)
    }
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...