DELETE triples with specific predicate not working

The following query returns 1423 triples:
?s ?p ?o .
filter(?p = skos:broader)

After successfully running this DELETE query:
?s skos:broader ?o .

I ran again the SELECT query and getting back the same 1423 triples.

Any idea why?
Do I need to commit after delete?


Hi Radu,

In the following example, I am using a different syntax that works fine to delete all triples related to a given resource type.

with graph_iri
{?s ?p ?o}
where {
?s rdf:type onto:resourceType .
?s ?p ?o }

I believe you should do:

{?s ?p ?o}
where {
values(?p) {(skos:broader)}
?s ?p ?o }


Thanks for trying to help me.

No errors running what you recommended but select still shows all 1423 broaders :frowning:


Hi Radu,

I can't seem to reproduce your issue. Do you have an example minimal data set where you reliably see this behavior? What version of Stardog are you using?

Here is the content of the exported trig file. Once you create a stardog db you will need to add arch type - skos= and also check query all graphs. TIA.

@prefix rdf: <> .
@prefix rdfs: <> .
@prefix skos: <> .
@prefix skosxl: <> .
@prefix owl: <> .
@prefix dc: <> .
@prefix dcterms: <> .
@prefix xsd: <> .
@prefix tags: <> .
@prefix foaf: <> .
@prefix cycAnnot: <> .
@prefix csw: <> .
@prefix dbpedia: <> .
@prefix freebase: <> .
@prefix opencyc: <> .
@prefix cyc: <> .
@prefix ctag: <> .

<> {<> skos:prefLabel "Four"@en;
dcterms:created "2019-01-02T16:29:28.395Z"^^xsd:dateTime .
<> dcterms:title "One"@en;
dcterms:created "2019-01-02T16:28:58.029Z"^^xsd:dateTime;
a skos:ConceptScheme;
rdfs:label "One"@en;
dcterms:creator <> .
<> dcterms:created "2019-01-02T16:29:09.540Z"^^xsd:dateTime;
dcterms:creator <>;
skos:topConceptOf <>;
skos:prefLabel "Two"@en .
<> skos:hasTopConcept <> .
<> a skos:Concept .
<> skos:broader <>;
dcterms:created "2019-01-02T16:29:19.358Z"^^xsd:dateTime;
a skos:Concept;
skos:prefLabel "Three"@en .
<> skos:narrower <> .
<> dcterms:creator <> .
<> skos:broader <>;
a skos:Concept .
<> skos:narrower <> .
<> dcterms:creator <> .


Since you have query.all.graphs=true your SELECT query would return data in any number of named graphs, however your DELETE query would still need to specify the named graph in order to delete the data.

If you want it gone from all graphs you can run the following:

  graph <tag:stardog:api:context:all> {
    ?s skos:broader ?o .


What you are saying it makes sense. However after issuing the above delete - I am still getting two rows after select :frowning:

BTW - I had also to add an entry into Namespaces:

Thanks for trying to help,

If you run SELECT * { graph ?g {?s skos:broader ?o} }, do you get a graph name bound in those 2 rows?

It might be a little overkill, but the following should clobber all of the triples:

DELETE {?s skos:broader ?o} WHERE {?s skos:broader ?o};
DELETE {GRAPH ?g {?s skos:broader ?o} } WHERE { GRAPH ?g {?s skos:broader ?o} }

Yes the select above returned 2 rows.

And yes this time the two triples are gone. Thank you.

I don't know why we need two delete statements though ... but could it be because skos:narrower is part of a symmetric relation - and not allowing a one delete statement to do its job? ... a mystery for now.

Thanks again,

The Sparql spec does not specify what the “default graph” actually is.

“Depending on implementation, the unnamed graph may refer
to a separate graph, a graph describing the named graphs, a representation of a union of other graphs, etc.”

So, you cannot assume that a Delete operation on the default graph will also delete triples from other named graphs.

1 Like

Also, see here and specifically the query.all.graphs option.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.