Your guide to what's next.
Home › Eckher Insights › Introduction to SPARQL
Apr 2, 2020

Introduction to SPARQL

SPARQL is a query language for graph data. The graph model of thinking fits well a lot of use cases.

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:

<> <> <> .
<> <> "Alice" .
<> <> "Bob" .

The dataset above intrinsically represents a graph:

Alice knows Bob

Example SPARQL query

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

SELECT ?name
    ?person <> <> .
    ?person <> ?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:

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

See also
What is Wikidata?
What is the Google Knowledge Graph?
Is it the world's largest knowledge base?
Article structured data
Article structured data examples.
What is Speech Synthesis Markup Language (SSML) and how to use it?
Your guide to what's next.
Copyright © 2021 Eckher. Various trademarks held by their respective owners.