0

I'm building a REST API which will serve information about statements stored in my Jena TDB.

It would be great if each statement has its unique ID so I can use this ID in GET request to retrieve information about particular statement. Is there something like that in Jena?

I know I can retrieve statement(s) by providing appropriate subject/predicate/object identifiers to model.listStatements method, but it would be quite ugly to add these parameters to API GET requests.

user3024710
  • 515
  • 1
  • 6
  • 15

2 Answers2

1

In RDF, a triple is defined by its subject, object and predicate. If you have two triples with the same S/P/O, it is really the same triple (value-equality, not instance equality). An RDF graph is a set of triples; if you add a triple twice, the set has only one instance. There is no triple id concept in RDF, and there isn't internally in TDB.

AndyS
  • 16,345
  • 17
  • 21
0

So you could use unique identifiers, say a string of length 4, for every S, every P and every O. Just save them all as key/value (id/resource, id/property) pairs. Then you will have a string of length 12 as unique identifier of your statement.

Even if a statements is deleted and added again, leading to a different id when tagging every statement with an id, this method will yield the same statement every time.

Laurens Koppenol
  • 2,946
  • 2
  • 20
  • 33