2

I am in the process of converting a graph to relational database. The schema of the RDB I am converting to requires each person to have a unique ID in the form of an integer. I have unique ID's for all my persons in the form of a URI.

is it possible to convert from URI -> Integer in a consistent manner to produce unique integer identifiers?

I have tried:

bind(xsd:integer(?person_id) as ?person_id_int)

bind(xsd:integer(str(?person_id)) as ?person_id_int)

I am using Ontotext GraphDB, the documentation states that

xsd:integer(rdfTerm value) - Casts value to xsd:integer

But I get no result when I try to bind the result of that to a variable.

example of a URI I'm trying to convert: https://biomedit.ch/rdf/sphn-resource/CHE-229_707_417-sphn-SubjectPseudoIdentifier-cdaea016-0449-46e5-9fbb-e44c0ecf0bed

Thanks in advance!

4
  • xsd:integer is a constructor function analogous to XPath: w3.org/TR/sparql11-query/#FunctionMapping - indeed it doesn't work for any string that can't be parsed as a valid integer number. My question would be, what would you expect as an outcome of xsd:integer("biomedit.ch/rdf/sphn-resource/…)`? Commented Nov 5, 2024 at 8:05
  • And even if it would compute some magic number, in SPARQL each binding aka row is being processed separately, so there would be nothing that prevents it from assigning the same value unless your magic function. What you're interested in is some auto-number of row number, something in the SQL world exists for window functions - I'm not aware of anything in standard SPARQL. I think you will need some custom property function that keeps track of all bindings in a group graph pattern then. Commented Nov 5, 2024 at 8:06
  • I think what I was hoping for was indeed some magic function, similar to SHA256, that computes an integer (yes, it will probably be pretty long) consistently given the same input string (or str(<someuri>)). I guess it doesn't exist, meaning I could write the logic myself (it will be a pretty disgustingly long SPARQL query to parse a string of unknown length, and convert each character to a set integer and concatenate it all together or something), but I could imagine that someone else has wrestled this pig before given the pretty common usecase of converting graphs to RDB's Commented Nov 5, 2024 at 8:49
  • IIRC, there was ent:id() in GraphDB (PREFIX ent: <http://www.ontotext.com/owlim/entity#>). Commented Nov 5, 2024 at 9:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.