Negation

Negation allows to refer to conditions where an answer exists or does not exists.

For instance making a small select statement on a database with three individuals in it for which not all the name is given but the type Person is defined.

If one wants to select all person from a database where one specific attribute is not available then one can do this with the filter expression NOT EXISTS, where one can say FILTER NOT EXIST the name, or a Triple that has a foaf name in it. With such a simple filter NOT EXISTS one can filter out results and therefore give specific things that should not be provides in the results.

  • Filter of Query solutions is done within a FILTER expression using NOT EXISTS and EXISTS

Data:

@prefix : <http://example/>] .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>]
@prefix foaf: <http://xmlns.com/foaf/0.1/>] .

:hevok rdf:type foaf:Person .
:hevok foaf:name "Hevok" .
:eva   rdf:type foaf:Person .

Query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-nx#>]
PREFIX foaf: <http://xmlns/foaf/0.1/>]
SELECT ?person
WHERE 
{
    ?person rdf:type foaf:Person .
    FILTER NOT EXISTS { ?person foaf:name ?name }
}

Result

?person
eva
Pact_of_Negation_640.jpg/
Edit tutorial

Comment on This Data Unit