Semantic knowledge base
Federated queries
Federated queries do sound like a complex area of the semantic technologies environment but are quite simply to understand if approached by components.
We have designed an example of a federated query that perfectly describes how such a technique can make use of existing alignments to enrich one resource with properties found in another. In addition it does this by using an intermediary dataset. This example shows the power behind the Linked Open Data principles.
We have started with 3 resources:
Not all of them are linked directly, but alignments have been done between the following pairs:
- EuroVoc – wikidata.org
- EuroVoc - Country Authority table
The demonstration will make use of both alignments to associate a set of properties from wikidata.org to a concept found in the Country Authority table.
The objective will be to find some properties that define the concept Luxembourg, that in the Country Authority table is identified with the following URI: http://publications.europa.eu/resource/authority/country/LUX
The relation will be constructed using the two existing alignments and accessing the datasets thru their respective SPARQL endpoints.
The federated query will be executed on the SPARQL endpoint of the Publications Office ( http://publications.europa.eu/webapi/rdf/sparql ) where the Country Authority table can be found.
The other two resources will be accessed on their SPARQL endpoints as well:
- for EuroVoc, we will use the same SPARQL endpoint of the Publications office: http://publications.europa.eu/webapi/rdf/sparql
- for wikidata.org: https://query.wikidata.org/sparql
In summary, the scope of the query is to add to a country concept fund in the Country Authority table a set of properties from wikidata.org, using the link that EuroVoc creates between those two resources.
The SPARQL script is listed below with the necessary comments to make it easy to understand.
PREFIX
skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX
wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd:
<http://www.wikidata.org/entity/>
PREFIX wikibase:
<http://wikiba.se/ontology#>
PREFIX bd:
<http://www.bigdata.com/rdf#>
# Define the structure of the result
SELECT
?countryLabel ?capital ?headOfGov ?population ?flag ?anthem
?geoshape
WHERE {
# Extract the EuroVoc URI of the concept from the Country
Authority table
service
<http://publications.europa.eu/webapi/rdf/sparql> {
# Identify the EuroVoc ID of the Country concept
?EuroVocID skos:closeMatch|skos:exactMatch
<http://publications.europa.eu/resource/authority/country/LUX>
.
# Select the prefLabel (preferred label) of the
concept
?EuroVocID skos:prefLabel ?countryLabel
# Keep just the English version of the prefLabel
FILTER (lang(?countryLabel)="en").
}
# Indicate the SPARQL endpoint where EuroVoc mappings can
be found
service
<http://publications.europa.eu/webapi/rdf/sparql> {
# Get the Wikidata URI associated with the EuroVoc
concepts
?EuroVocID skos:closeMatch|skos:exactMatch ?wikiURI
.
}
# Look into the SPARQL endpoint of wikidata.org
service <https://query.wikidata.org/sparql> {
# Get Wikidata properties associated with the URI
?wikiURI wdt:P36 ?capital .
?wikiURI wdt:P6
?headOfGov .
?wikiURI wdt:P1082 ?population .
?wikiURI wdt:P41 ?flag .
?wikiURI wdt:P85 ?anthem .
?wikiURI wdt:P3896 ?geoshape
}
}
Most Recent
About the use of Named Authority Lists (NALs)
23 ta’ Mejju 2025
How to extract a list of concepts from a vocabulary
23 ta’ Mejju 2025
Dissemination formats
23 ta’ Mejju 2025
useContext property and how to use it
23 ta’ Mejju 2025
Resource alignments: Main elements of a proper methodology
23 ta’ Mejju 2025
Labels and data models, why and how to use them
23 ta’ Mejju 2025
Identifiers and how to use more than one
23 ta’ Mejju 2025
Semantic technologies in practice
23 ta’ Ottubru 2021
About reference data
23 ta’ Ottubru 2021
|
Most Popular
Dissemination formats
57022 Views
useContext property and how to use it
55469 Views
About the use of Named Authority Lists (NALs)
53205 Views
Labels and data models, why and how to use them
52495 Views
Identifiers and how to use more than one
50446 Views
About reference data
37808 Views
Semantic technologies in practice
36008 Views
|