1

What I want:

If you have 2 triples in GraphDB as:

<ex:s_1> <ex:p_1> <ex:o_1> .
<ex:s_1> <ex:p_1> <ex:o_1> <ex:g_1> .

How can I delete only the one in the default graph with a DELETE DATA query?

I am trying to do this in a query that may also be deleting many other triples/quads from named graphs at the same time. I'd prefer not to use FROM DEFAULT or FROM <http://rdf4j.org/schema/rdf4j#nil> because then I have to include all the FROM NAMED <xxx> that I would need as well which could be a lot, though I can do that if that is the only way.

What I did:

The GraphDB documentation says that the URI http://rdf4j.org/schema/rdf4j#nil represents the default graph and it works and gives YES correctly when used in an ASK query. That seems promising. This seems to work correctly (well, the way I'd like it to):

ASK
WHERE {
    GRAPH <http://rdf4j.org/schema/rdf4j#nil> {
    <ex:s_1> <ex:p_2> <ex:o_3> .
    }
}

So I tried to use it in my DELETE DATA query as:

DELETE DATA {
    GRAPH <http://rdf4j.org/schema/rdf4j#nil> {
        <ex:s_1> <ex:p_2> <ex:o_3> .
    }
};

But this does not delete it. No error, but no delete either. So it seems to only have limited usefulness, you get an error when trying to use that in an INSERT. I haven't found this level of specifics in the documentation as to what works or what doesn't.

And this, deletes both:

DELETE DATA {
  <ex:s_1> <ex:p_2> <ex:o_3> .
};
Feisty Dev
  • 11
  • 2
  • Does ```delete data { graph { 1 . } }``` works for You? – Damyan Ognyanov May 02 '23 at 06:13
  • why does GraphDB delete the triples also in the named graph with the latter query? That is not what the standard says – UninformedUser May 02 '23 at 06:29
  • @DamyanOgnyanov thanks for that hint, it looks promising. I need to play with that a bit and see how well it works. – Feisty Dev May 02 '23 at 18:50
  • @UninformedUser different triplestores treat the datasets used by default for SPARQL queries differently. Some, like GraphDB, put all triples (the union of all graphs) in the "default graph". This makes it easy to query the graph without regard to named graphs. But it complicates queries where you really want to specify only triples in the default graph. This part of SPARQL is not fully specified; there is a proposal for v1.2 to help with some of this. – Feisty Dev May 02 '23 at 18:56

0 Answers0