Home › Resources & tools › Introduction to SPARQL

Introduction to SPARQL

SPARQL is a query language for RDF data. It is commonly used in semantic web, linked data, and big data applications. There is a growing number of websites and organizations that provide SPARQL endpoints for querying their public data like Wikidata and DBpedia.

What is RDF?

An RDF dataset is simply a set of subject-predicate-object triples. This way of conceptually describing or modeling data is different to the commonly used relational model and is very useful for semantic web applications.

Here is an example of an RDF document in the N-triples/Turtle format:

<http://example.org/#alice> <http://xmlns.com/foaf/0.1/knows> <http://example.org/#bob> .
<http://example.org/#alice> <http://xmlns.com/foaf/0.1/name> "Alice" .
<http://example.org/#bob> <http://xmlns.com/foaf/0.1/name> "Bob" .

Example SPARQL query

Here is an example of a SPARQL query against the RDF dataset:

SELECT ?name
WHERE
{
  ?person <http://xmlns.com/foaf/0.1/knows> <http://example.org/#bob> .
  ?person <http://xmlns.com/foaf/0.1/name> ?name .
}

This query searches for all matching sets of triples and returns the list of names of every person that knows Bob.

Public SPARQL endpoints

You can start writing and executing SPARQL queries right away using interactive SPARQL query services. The table below lists the SPARQL query services that provide access to public datasets:

Website/OrganizationURL
Wikidatahttps://query.wikidata.org/
DBpediahttps://dbpedia.org/sparql
EUhttps://data.europa.eu/euodp/sparqlep
UK Governmenthttp://statistics.data.gov.uk/sparql
UNESCOhttp://vocabularies.unesco.org/sparql-form/
UniProthttps://sparql.uniprot.org/

The websites listed above are the best way to get started with SPARQL because they allow you to run queries without having to set anything up.

Further reading

For an in-depth discussion about SPARQL, take a look at Bob DuCharme's Learning SPARQL: Querying and Updating with SPARQL 1.1 published by O'Reilly Media. For a more technical overview of SPARQL, visit W3C's SPARQL 1.1 Overview.

See also

Big Phonetic Symbols
$29.99

Explore the fine details of the characters used to communicate the sounds of human speech.

Ewe Alphabet Poster, English-Labeled
$17.99

The Ewe alphabet chart.

Dodecahedrane Molecule Poster, Ball-and-Stick Model, English-Labeled
$19.99

A poster featuring the ball-and-stick model of the dodecahedrane molecule.

Inuktitut Syllabics Poster
$19.99

A poster featuring the Inuktitut syllabics chart.

Circle of Fifths Poster, English-Labeled
$19.99

A poster featuring the circle of fifths diagram.

Why federation is a game-changing feature of SPARQL

SPARQL federation is an incredibly useful feature for querying distributed RDF graphs.

SPARQL Parse Tree Viewer

Visualize the parse tree of SPARQL queries.

SPARQL Client

Query SPARQL endpoints online.

Let's explore the Nobel Prize dataset

An overview of the official Nobel Prize Linked Data dataset with some example SPARQL queries.

SPARQL Editor

A simple online editor for SPARQL (SPARQL Protocol and RDF Query Language) queries.

All prices listed are in United States Dollars (USD). Visual representations of products are intended for illustrative purposes. Actual products may exhibit variations in color, texture, or other characteristics inherent to the manufacturing process. The products' design and underlying technology are protected by applicable intellectual property laws. Unauthorized reproduction or distribution is prohibited.