3

Good day, I am using Graphdb to store some triples as seen in the image below. This particular RDF node uses a regular URI http://example/regular/uri. What I wish to do is to not only completely delete all properties attached to this node, but also delete the node itself. (with the result that http://example/regular/uri does not appear in the graph database any longer)

RDF node example in graphdb

So far I am only able to delete all properties, but I am not able to delete the actual RDF node itself. It seemed rather simple, but the more I research online, the more this seems impossible unless clearing the complete graph.

I have tried simple "delete where" queries as shown in example 11 of SPARQL documentation. And i have also tried using simple "delete where"-queries using the wildcard operator as shown in the query below:

enter image description here

Is there a way to delete such RDF nodes? Thanks in advance!

  • can you explain what you mean by "delete node"? And RDF dataset consist of RDF triples, thus, you can only delete RDF triples. Nodes are parts of triples but never exist alone – UninformedUser Jun 18 '19 at 16:48
  • @AKSW Thanks for the comment. yes, I had trouble giving it a name as well, but graphdbh calls them that . the RDF 'node' is simply the object identified with the URI. In this example I am able to delete the properties of the triples (for example deleting the "dc:language"-relationship and its value "english") But if I delete every single property of this object, (in this case ) the 'object' still exists, only without properties. So this object, while it doesn't serve any use anymore, still appears in my graph database. Did I manage to explain it somehow? – Andrew Malcolm Jun 18 '19 at 17:06
  • 1
    Did you verify that no triples exist after the delete? just doing `select * { { ?p ?o} union {?s ?p }}` or `describe ` ? – UninformedUser Jun 18 '19 at 19:02

2 Answers2

3

A node exists in a graph as long as there is one or more triples with that node in subject or object position. So the easiest way would be to issue two delete statements, one deleting all statements with the node in subject position and one deleting all statements with the node in object position. But if you need/want to do it with a single operation you can do that as well with filters.

Reto Gmür
  • 2,497
  • 1
  • 20
  • 25
  • 1
    Yes, it has mostly to do with me not really understanding rdf yet. It dissappeared once all relationships with the node were gone. – Andrew Malcolm Jun 21 '19 at 14:45
1

Here is a sample that delete uri://node/to/delete from uri://my/graph :

DELETE { GRAPH <uri://my/graph> {   
   ?s ?p ?o .
}}
USING <uri://my/graph>
WHERE {
  { 
    ?s ?p ?o .   VALUES ?s { <uri://node/to/delete>}
  } UNION {
    ?s ?p ?o .   VALUES ?o { <uri://node/to/delete>}
  }
}
Paul Cuddihy
  • 477
  • 6
  • 12