Skip to content


Don’t just assume people will resolve URIs

Some RDF documents are very large and not intended for immediate consumption, but rather loading into an endpoint or complex analysis.

However, others are intended for more-or-less stand alone use. Examples would include a FOAF profile or the RDF event programme that we’ve been working on. Having worked with a few of these as a developer, I suggest that it is good practice to include an rdf:type and a suitable label (dc:title, foaf:name, rdfs:label, skos:prefLabel) for them. This makes working with them much much easier.

For example if you include:

example:myphoto foaf:depicts <http://dbpedia.org/resource/Andrew_Eldritch> .

That’s all fine and good, but I can’t actually render that into, say, a caption without at least knowing…

<http://dbpedia.org/resource/Andrew_Eldritch> foaf:name "Andrew Eldritch" .

Resolving secondary URIs from a document is expensive, if done on-the-fly. Any reduction is very helpful, so if I’m trying to, say, index-by-Person the photos described in your photo collection RDF then knowing…

<http://dbpedia.org/resource/Andrew_Eldritch> rdf:type foaf:Person .

…would also help a hacker out.

The new version of the Graphite RDF Browser and SPARQL Browser both show this information if it’s available, and it makes things much easier to work with, for example, the Data.gov.uk schools data is pretty good for give a label to everything and a type to most things.

The SPARQL Browser attempts to get labels, using the following ugly but surprisingly fast query:

SELECT DISTINCT ?s ?p ?o WHERE {
{ <http://id.ecs.soton.ac.uk/person/1248> ?x ?s . ?s ?p ?o . ?s <http://www.w3.org/2000/01/rdf-schema#label> ?o .  }  UNION
{ <http://id.ecs.soton.ac.uk/person/1248> ?x ?s . ?s ?p ?o . ?s <http://purl.org/dc/terms/title> ?o .  }  UNION
{ <http://id.ecs.soton.ac.uk/person/1248> ?x ?s . ?s ?p ?o . ?s <http://purl.org/dc/elements/1.1/title> ?o .  }  UNION
{ <http://id.ecs.soton.ac.uk/person/1248> ?x ?s . ?s ?p ?o . ?s <http://xmlns.com/foaf/0.1/name> ?o .  }  UNION
{ ?s ?x <http://id.ecs.soton.ac.uk/person/1248> . ?s ?p ?o . ?s <http://www.w3.org/2000/01/rdf-schema#label> ?o .  }  UNION
{ ?s ?x <http://id.ecs.soton.ac.uk/person/1248> . ?s ?p ?o . ?s <http://purl.org/dc/terms/title> ?o .  }  UNION
{ ?s ?x <http://id.ecs.soton.ac.uk/person/1248> . ?s ?p ?o . ?s <http://purl.org/dc/elements/1.1/title> ?o .  }  UNION
{ ?s ?x <http://id.ecs.soton.ac.uk/person/1248> . ?s ?p ?o . ?s <http://xmlns.com/foaf/0.1/name> ?o .  }  UNION
}

And then a similar one for rdf:type. These are both, of couse, subject to the max-results of the SPARQL endpoint. As in the past I was an SQL programmer, this limit bites me again and again.

Posted in Best Practice, Graphite, RDF, SPARQL.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.