← every query · class 09 · queries/without-manufacturer.rq
Products with no manufacturer (FILTER NOT EXISTS)
The same answer in both regimes: this query asks only for what was written.
(zero rows) — an empty answer is not an error: in an open world, nothing matched.
The query
# Negation: products with no declared manufacturer (slide "Filters, optionals
# and negation"). On the graph as delivered it returns zero rows — and that is
# the point: the query is right, it is the data that is complete. Over
# domain-bad.ttl it returns zero rows too: product:58 does have a manufacturer,
# only it is the string "Acme Lda". NOT EXISTS checks that a value is there,
# not what kind of value it is — that is a job for SHACL (example 07).
PREFIX onto: <https://data.csoares.me/onto#>
SELECT ?p
WHERE {
?p a onto:Product .
# ?m is used only inside the NOT EXISTS: any value at all counts
FILTER NOT EXISTS { ?p onto:manufacturedBy ?m }
}