Chapter 5

Federation

Query the entire Linked Data web. Use SERVICE to combine data from multiple SPARQL endpoints in a single query — Wikidata, DBpedia, and beyond.

Endpoints
SERVICE
Keyword
Advanced
Level

The Power of Linked Data

No single knowledge base contains all the information you need. Wikidata might have an entity, but DBpedia has additional details, or another specialized endpoint has domain-specific data.

SPARQL federation solves this with the SERVICE keyword. Execute parts of your query against remote endpoints and combine results seamlessly — all from a single query.

This is the vision of the Semantic Web: interconnected data that can be queried as if it were a single giant database.

How Federation Works

Federation Structure
SELECT ?localVar ?remoteVar
WHERE {
  # Local patterns (run on current endpoint)
  ?item wdt:P31 wd:Q9143 .

  # Remote patterns (run on external endpoint)
  SERVICE <http://dbpedia.org/sparql> {
    ?dbpediaItem owl:sameAs ?item .
    ?dbpediaItem foaf:homepage ?remoteVar .
  }
}

The query engine sends the SERVICE block to the remote endpoint, receives the results, and joins them with local results based on shared variables.

Federation Topics

🔗

SERVICE Keyword

The core of SPARQL federation. Learn syntax, variable passing, and how to structure federated queries effectively.

Advanced Core concept
Learn SERVICE
🌐

SPARQL Endpoints

Discover useful public endpoints: DBpedia, Getty Vocabularies, Europeana, and domain-specific knowledge bases.

Intermediate Data sources
Explore Endpoints
🧩

Federation Patterns

Common patterns for effective federation: entity linking, enrichment, cross-validation, and aggregation.

Advanced Best practices
View Patterns

Federation Examples

Wikidata + DBpedia

Enrich Wikidata with DBpedia
Run ↗
SELECT ?lang ?langLabel ?homepage
WHERE {
  # Get programming languages from Wikidata
  ?lang wdt:P31 wd:Q9143 .

  # Get homepage from DBpedia via sameAs link
  SERVICE <http://dbpedia.org/sparql> {
    ?dbpediaLang owl:sameAs ?lang ;
                  foaf:homepage ?homepage .
  }

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}
LIMIT 10

SERVICE SILENT

Graceful Failure Handling
SELECT ?lang ?langLabel ?homepage
WHERE {
  ?lang wdt:P31 wd:Q9143 .

  # SILENT: Don't fail if endpoint is unavailable
  SERVICE SILENT <http://dbpedia.org/sparql> {
    ?dbpediaLang owl:sameAs ?lang ;
                  foaf:homepage ?homepage .
  }

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}
LIMIT 10

Popular SPARQL Endpoints

Endpoint URL Domain
Wikidata https://query.wikidata.org/sparql General knowledge
DBpedia http://dbpedia.org/sparql Wikipedia data
Getty Vocabularies http://vocab.getty.edu/sparql Art & cultural heritage
UniProt https://sparql.uniprot.org/sparql Proteins & biology
LinkedGeoData http://linkedgeodata.org/sparql OpenStreetMap data

Federation Best Practices

You've Completed the Core Chapters!

Congratulations! You've learned SPARQL from basic queries to advanced federation. Continue exploring with more examples or revisit any chapter.

🚀

← Advanced Queries

Review ASK, CONSTRUCT, and DESCRIBE.

Go Back
📘

Start Over →

Review the basics or explore more examples.

Basic Queries