Friday, August 27, 2010

Prefixes in SPARQL Queries

While still using the dbpedia Virtuoso browser, http://dbpedia.org/sparql, pointing to a single page about Joan Baez, lets explore the use of prefixes to shorten our links.

Prefixes facilitate communication by helping you use standard predicates and objects to describe your data so the user doesn't have to work so hard to understand you.

SUPPLYING THE RIGHT PREDICATE FOR RDF:TYPE

Viewing the source of the Come from the Shadows page, and looking for the string, rdf:type, I find a simpler URI to use, http://www.w3.org/1999/02/22-rdf-syntax-ns# which works.


SELECT * WHERE 
{?s 
    <http://dbpedia.org/ontology/artist>
       <http://dbpedia.org/resource/Joan_Baez> ;
    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type > 
       ?type.
}
See the results.

ABBREVIATE A PREDICATE USING A PREFIX

Instead of using the full URI in the previous example, I can:

1) define a prefix, rdf:,

2) list the URI to identify the prefix enclosed in angled brackets, and then

3) use the prefix to express a URI more compactly, rdf:type

Doing that gives us the same results.


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE 
{?s 
    <http://dbpedia.org/ontology/artist>
       <http://dbpedia.org/resource/Joan_Baez> ;
     rdf:type 
       ?type.
}
See the results.

Using the URI of the prefix, we can go to that web page and learn more about related predicates that might be available in that namespace. These namespaces are important for explaining whether, for example, the chip we are discussing is a computer chip, a potato chip, a paint chip or a cow chip.


OTHER COMMON PREFIX



PREFIX owl: <http://www.w3.org/2002/07/owl#>

Provides metadata about concepts and how they are related to other concepts.


PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

Provides information about how the information is structured and often used to specify the data type of a particular piece of information.


PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

Provides metadata about the RDF data such as related concepts, user friendly labels, comments about the information.


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

Provides very fundamental classification of the information.


PREFIX foaf: <http://xmlns.com/foaf/0.1/>

Provides information about people and their inter-relationships (friend of a friend), and how to contact them.


PREFIX dc: <http://purl.org/dc/elements/1.1/>

Provides the Dublic Core items of metadata. It is often used to describe published information and the publisher of that information.


PREFIX : <http://dbpedia.org/resource/>

With this empty prefix, we could then refer to the dbpedia resource <http://dbpedia.org/resource/Joan_ Baez> simply as :Joan_Baez


PREFIX dbpedia2: <http://dbpedia.org/property/>

This describes the properties that Dbpedia uses to describe things or subjects it has information about. These properties are appropriate to the thing, so a river would have a different set of pre-defined properties than a mathemetician.


PREFIX dbpedia: <http://dbpedia.org/>

Provides information coming from dbpedia..


PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

Simple Knowledge Organization System (SKOS) is a common data model for sharing and linking knowledge organization systems via the Semantic Web.


PREFIX dbo: <http://dbpedia.org/ontology/>

Provides metadata about what entities exist, how they can be grouped, how they related within a hierarchy, and how they can be subdivided according to similarities and differences.

No comments:

Post a Comment