Last active
August 29, 2015 14:27
-
-
Save ColinMaudry/fdc466383fdfd0dd24d2 to your computer and use it in GitHub Desktop.
Examples of SPARQL queries on data.gov.uk metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#List of all the named graphs in the repository. <http://www.data.maudry.com/uk> is the named | |
#graph where most of the data is stored. | |
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | |
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | |
PREFIX dcat: <http://www.w3.org/ns/dcat#> | |
PREFIX dgfr: <http://colin.maudry.com/ontologies/dgfr#> | |
select distinct ?graph where { | |
graph ?graph { | |
?s ?p ?o | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#List of RDF classes and for each, the number of instances | |
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | |
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | |
PREFIX dcat: <http://www.w3.org/ns/dcat#> | |
PREFIX dgfr: <http://colin.maudry.com/ontologies/dgfr#> | |
select distinct ?class (count(?thing) as ?numInstances) where { | |
graph <http://www.data.maudry.com/uk> { | |
?thing a ?class . | |
} | |
} | |
group by ?class | |
order by ?class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#List of the organizations, ordered by number of published datasets. | |
#It also includes the number of distributions (actual files or resources). | |
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | |
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX dcat: <http://www.w3.org/ns/dcat#> | |
PREFIX dcterms: <http://purl.org/dc/terms/> | |
SELECT ?organization (count (distinct ?dataset) as ?numDatasets) | |
(count (distinct ?distribution) as ?numDistributions) | |
WHERE { | |
graph <http://www.data.maudry.com/uk> { | |
?dataset a dcat:Dataset ; | |
dcterms:publisher ?organization ; | |
dcat:distribution ?distribution . } | |
} | |
group by ?organization | |
order by desc(?numDatasets) | |
limit 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment