Re: How to Transform Hand-crafted URIs to UUIDs

On 15/03/2023 03:00, Tim McIver wrote:
> Hello,
> WHERE {
>    SELECT ?person ?firstName ?lastName ?gender
>    {
>      BIND(UUID() AS ?person)
>      ?p a schema:Person ;
>         schema:givenName ?firstName ;
>         schema:familyName ?lastName ;
>         schema:gender ?gender .
>    }
> }

The SELECT will create one UUID because BIND operates on the pattern 
before it, and the initial empty pattern has one row.


Try moving it after ?p finding the the ?p by type:

    SELECT ?person ?firstName ?lastName ?gender
    {
      ?p a schema:Person .
      BIND(UUID() AS ?person)
      ?p schema:givenName ?firstName ;
         schema:familyName ?lastName ;
         schema:gender ?gender .
    }

     Andy

You may wish to add OPTIONALs in case the data is a bit imperfect:

    SELECT ?person ?firstName ?lastName ?gender
    {
      ?p a schema:Person .
      BIND(UUID() AS ?person)
      OPTIONAL { ?p schema:givenName ?firstName }
      OPTIONAL { ?p schema:familyName ?lastName }
      OPTIONAL { ?p schema:gender ?gender }
    }


> Thank you,
> Tim
> 

Received on Wednesday, 15 March 2023 18:01:39 UTC