DESCRIBE (Informative)
The DESCRIBE form returns a single result RDF graph containing RDF data about resources. This
data is not prescribed by a SPARQL query, where the query client would need to know
the structure of the RDF in the data source, but, instead, is determined by the SPARQL
query processor. The query pattern is used to create a result set. The DESCRIBE form takes each of the resources identified in a solution, together with any resources
directly named by IRI, and assembles a single RDF graph by taking a "description"
which can come from any information available including the target RDF Dataset. The
description is determined by the query service. The syntax DESCRIBE * is an abbreviation that describes all of the variables in a query.
Explicit IRIs
The DESCRIBE clause itself can take IRIs to identify the resources. The simplest DESCRIBE query is just an IRI in the DESCRIBE clause:
DESCRIBE <http://example.org/>
Identifying Resources
The resources to be described can also be taken from the bindings to a query variable in a result set. This enables description of resources whether they are identified by IRI or by blank node in the dataset:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DESCRIBE ?x
WHERE { ?x foaf:mbox <mailto:alice@org> }
The property foaf:mbox is defined as being an inverse functional property in the FOAF vocabulary. If treated
as such, this query will return information about at most one person. If, however,
the query pattern has multiple solutions, the RDF data for each is the union of all
RDF graph descriptions.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DESCRIBE ?x
WHERE { ?x foaf:name "Alice" }
More than one IRI or variable can be given:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DESCRIBE ?x ?y <http://example.org/>
WHERE {?x foaf:knows ?y}
Descriptions of Resources
The RDF returned is determined by the information publisher. It may be information the service deems relevant to the resources being described. It may include information about other resources: for example, the RDF data for a book may also include details about the author.
A simple query such as
PREFIX ent: <http://org.example.com/employees#>
DESCRIBE ?x WHERE { ?x ent:employeeId "1234" }
might return a description of the employee and some other potentially useful details:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0> .
@prefix exOrg: <http://org.example.com/employees#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#>
_:a exOrg:employeeId "1234" ;
foaf:mbox_sha1sum "bee135d3af1e418104bc42904596fe148e90f033" ;
vcard:N
[ vcard:Family "Smith" ;
vcard:Given "John" ] .
foaf:mbox_sha1sum rdf:type owl:InverseFunctionalProperty .
which includes the blank node closure for the vcard vocabulary vcard:N. Other possible mechanisms for deciding what information to return include Concise Bounded Descriptions [CBD - Concise Bounded Description].
For a vocabulary such as FOAF, where the resources are typically blank nodes, returning
sufficient information to identify a node such as the InverseFunctionalProperty foaf:mbox_sha1sum as well as information like name and other details recorded would be appropriate.
In the example, the match to the WHERE clause was returned, but this is not required.
Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang). This software or document includes material copied from or derived from SPARQL 1.1 Query.