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 <> .

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

<> 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…

<> 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 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:

{ <> ?x ?s . ?s ?p ?o . ?s <> ?o .  }  UNION
{ <> ?x ?s . ?s ?p ?o . ?s <> ?o .  }  UNION
{ <> ?x ?s . ?s ?p ?o . ?s <> ?o .  }  UNION
{ <> ?x ?s . ?s ?p ?o . ?s <> ?o .  }  UNION
{ ?s ?x <> . ?s ?p ?o . ?s <> ?o .  }  UNION
{ ?s ?x <> . ?s ?p ?o . ?s <> ?o .  }  UNION
{ ?s ?x <> . ?s ?p ?o . ?s <> ?o .  }  UNION
{ ?s ?x <> . ?s ?p ?o . ?s <> ?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.