3

I am writing an application using the Apache Jena framework. With this I am able to do everything (insert, update, select). But i can't wrap my head around how to properly insert blank nodes using an INSERT query.

Is there a go-to approach for this (which works with every endpoint)? I know SPARQL 1.1 introduced some features for this to be accomplished, but it does not seem to work using a Virtuoso endpoint.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
oole
  • 342
  • 3
  • 13
  • It can help to think of bNodes (blank nodes, unnamed nodes) as pronouns -- to be used when you don't know the proper name of an entity which does exist and to which you need to refer, whether to describe it or to describe other entities. For others to advise you, it helps to know what you've tried, what results you've gotten, and how these depart from what you expected/desired. – TallTed Apr 26 '16 at 16:43
  • If there is actually a Virtuoso-specific aspect to this, such questions are often answered more quickly and accurately through Virtuoso-focused forums like the [Virtuoso Users mailing list](https://lists.sourceforge.net/lists/listinfo/virtuoso-users), the [OpenLink Support Forums](http://boards.openlinksw.com/support/index.php), or an [OpenLink Support Case](http://support.openlinksw.com/support/online-support.vsp). (ObDisclaimer: I work for OpenLink Software, producer of Virtuoso.) – TallTed Apr 26 '16 at 16:55

1 Answers1

3

There are a couple of syntaxes to use. Suppose you want to add a bnode of type :Person to an object property named child. Here's one way:

?s :child [a :Person] .

And another:

?s :child [] .
[] a :Person .

And the _:bn notation is pretty universal, and useful when there are more than one bnode in a graph:

?s :child _:b0 .
_:b0 a :Person .
scotthenninger
  • 3,921
  • 1
  • 15
  • 24
  • 1
    "useful when there are more than one bnode in a graph:" I think it's most useful when you need to refer to a bnode multiple times. E.g,. `:s1 :p _:b0 . :s2 :p _:b0 `. – Joshua Taylor Apr 25 '16 at 23:21
  • Thank you for this answer. It made my vision of bNodes clearer. And i also kind of realized that it might not be possible to insert bNodes from a table with row-wise INSERT DATA queries. (And keeping the connection between the bNodes in the table). So i guess it would be wiser to find a way to insert a local model into the remote endpoint directly. – oole Apr 26 '16 at 13:58