This HTML5 document contains 33 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

PrefixNamespace IRI
n12http://docs.openlinksw.com/virtuoso/sparqlextensions.html#
dctermshttp://purl.org/dc/terms/
atomhttp://atomowl.org/ontologies/atomrdf#
foafhttp://xmlns.com/foaf/0.1/
n19http://vos.openlinksw.com/dataspace/services/wiki/
oplhttp://www.openlinksw.com/schema/attribution#
n2http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/
n16http://docs.openlinksw.com/virtuoso/rdfsparql.
dchttp://purl.org/dc/elements/1.1/
n6http://vos.openlinksw.com/dataspace/dav#
rdfshttp://www.w3.org/2000/01/rdf-schema#
n20http://rdfs.org/sioc/services#
siocthttp://rdfs.org/sioc/types#
n17http://vos.openlinksw.com/dataspace/person/dav#
n8http://vos.openlinksw.com/dataspace/owiki/wiki/
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
n11http://vos.openlinksw.com/dataspace/owiki#
xsdhhttp://www.w3.org/2001/XMLSchema#
siochttp://rdfs.org/sioc/ns#
n4http://vos.openlinksw.com/dataspace/person/owiki#
n14http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes/sioc.
Subject Item
n17:this
foaf:made
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
Subject Item
n6:this
sioc:creator_of
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
Subject Item
n19:item
n20:services_of
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
Subject Item
n11:this
sioc:creator_of
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
Subject Item
n8:VOS
sioc:container_of
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
atom:entry
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
atom:contains
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
Subject Item
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
rdf:type
atom:Entry sioct:Comment
dcterms:created
2017-06-13T05:38:37.142256
dcterms:modified
2019-10-21T09:31:32.419322
rdfs:label
VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
foaf:maker
n4:this n17:this
dc:title
VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
opl:isDescribedUsing
n14:rdf
sioc:has_creator
n6:this n11:this
sioc:content
%META:TOPICPARENT{name="VirtTipsAndTricksGuide"}% ---+ Can I Delete Triples containing Blank Nodes? There are two ways to delete a particular blank node: 1 Refer to it indirectly, using some of its properties, or 1 Discover and refer to it by its internal "serial number" or ID (in Virtuoso, <code><nowiki>bif:iri_id_XXX</nowiki></code>, a long integer). <i><b>Important Note</b>: IDs of bnodes will always vary from server to server, and often from run-to-run on the same server, so it is usually better to identify bnodes by properties than ID.</i> ---++ How to Delete Triples containing Blank Nodes Assume the following sample scenario: 1 Clear the graph: <verbatim> SPARQL CLEAR GRAPH <http://sample/>; Done. -- 4 msec. </verbatim> 1 Insert three blank nodes with two related triples each: <verbatim> SPARQL INSERT IN GRAPH <http://sample/> { [] <p> <o1a> , <o1b> . [] <p> <o2a> , <o2b> . [] <p> <o3a> , <o3b> }; Done. -- 15 msec. </verbatim> 1 Delete one pair of triples: <verbatim> SPARQL WITH <http://sample/> DELETE { ?s ?p ?o } WHERE { ?s ?p ?o ; <p> <o1a> } Done. -- 7 msec. </verbatim> 1 Ensure that we still have two bnodes, two triple per bnode: <verbatim> SPARQL SELECT * FROM <http://sample/> WHERE { ?s ?p ?o }; s p o VARCHAR VARCHAR VARCHAR _________________________________ nodeID://b10006 p o3a nodeID://b10006 p o3b nodeID://b10007 p o2a nodeID://b10007 p o2b 4 Rows. -- 4 msec. </verbatim> 1 Every node in the Virtuoso store, whether "named" or "blank" ("unnamed"), is identified internally by a long integer: <verbatim> SPARQL SELECT (<LONG::bif:iri_id_num>(?s)) AS ?s_num , ?p , ?o FROM <http://sample/> WHERE { ?s ?p ?o }; s_num p o INTEGER VARCHAR VARCHAR _____________________________ 4611686018427397910 p o3a 4611686018427397910 p o3b 4611686018427397911 p o2a 4611686018427397911 p o2b 4 Rows. -- 5 msec. </verbatim> 1 The integer can be converted back to internal identifier. Say, here we try to delete a triple that does not exist (even if the ID integer is valid): <verbatim> SPARQL DELETE FROM <http://sample/> { `bif:iri_id_from_num(4611686018427397911)` <p> <o3a> }; Done. -- 5 msec. </verbatim> 1 Should have no effect, because the "46..11" IRI has &lt;o2a&gt; and &lt;o2b&gt;, and was not requested &lt;o3a&gt;: <verbatim> SPARQL SELECT * FROM <http://sample/> WHERE { ?s ?p ?o }; s p o VARCHAR VARCHAR VARCHAR __________________________________ nodeID://b10006 p o3a nodeID://b10006 p o3b nodeID://b10007 p o2a nodeID://b10007 p o2b 4 Rows. -- 5 msec. </verbatim> 1 Now let's try to delete a triple that does actually exist. Note the use of backquotes to insert an expression into the graph template: <verbatim> SPARQL DELETE FROM <http://sample/> { `bif:iri_id_from_num(4611686018427397911)` <p> <o2a> }; Done. -- 4 msec. </verbatim> 1 This time, there's an effect: <verbatim> SPARQL SELECT * FROM <http://sample/> WHERE { ?s ?p ?o }; s p o VARCHAR VARCHAR VARCHAR _________________ nodeID://b10006 p o3a nodeID://b10006 p o3b nodeID://b10007 p o2b 3 Rows. -- 2 msec. </verbatim> 1 Now we'll delete everything related to <code>nodeID://b10006</code> subject: <verbatim> SPARQL WITH <http://sample/> DELETE { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER ( ?s = bif:iri_id_from_num(4611686018427397910) ) }; Done. -- 18 msec. </verbatim> 1 This should delete two of the previous three triples, leaving one remaining triple: <verbatim> SQL> SPARQL SELECT * FROM <http://sample/> WHERE { ?s ?p ?o }; s p o VARCHAR VARCHAR VARCHAR ___________________________________ nodeID://b10007 p o2b 1 Rows. -- 4 msec. </verbatim> ---++Related * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]] * [[http://docs.openlinksw.com/virtuoso/rdfsparql.html][Virtuoso Documentation]] * [[http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparulexamples14][Deleting triples from a graph]] * [[VirtTipsAndTricksGuideDeleteLargeGraphs][Deleting triples from a "Large" graph]]
sioc:id
c76eb5b41714494f98466b3f463dd393
sioc:link
n2:VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
sioc:has_container
n8:VOS
n20:has_services
n19:item
atom:title
VirtTipsAndTricksGuideDeleteTriplesWithBlanknodes
sioc:links_to
n2:VirtTipsAndTricksGuideDeleteLargeGraphs n12:rdfsparulexamples14 n2:VirtTipsAndTricksGuide n16:html
atom:source
n8:VOS
atom:author
n17:this
atom:published
2017-06-13T05:38:37Z
atom:updated
2019-10-21T09:31:32Z
sioc:topic
n8:VOS