Skip to content

Time-bounded subclasses

This Wikidata query finds subclass statements with start and end qualifiers, then returns their English labels. The captured JSON response contains 176 bindings.

echo 'PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?subclass ?subclassName ?superclass ?superclassName ?start ?end WHERE {
  ?subclass p:P279 ?subclassStatement .
  ?subclassStatement ps:P279 ?superclass ;
                     pq:P580 ?start ;
                     pq:P582 ?end .

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q22938576 .   # not a race (competition)
  }

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q3139516 .  # not an abbot or other church official
  }

  ?subclass rdfs:label ?subclassName .
  ?superclass rdfs:label ?superclassName .
  FILTER(LANG(?subclassName) = "en")
  FILTER(LANG(?superclassName) = "en")
}
ORDER BY ?subclassName ?start ?end' |
  vitrify sparql \
  --endpoint https://qlever.dev/api/wikidata \
  --query - \
  --format json \
  --to time-bounded-subclasses

time-bounded-subclasses/
├── query.rq
├── results.json
└── ro-crate-metadata.json

PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?subclass ?subclassName ?superclass ?superclassName ?start ?end WHERE {
  ?subclass p:P279 ?subclassStatement .
  ?subclassStatement ps:P279 ?superclass ;
                     pq:P580 ?start ;
                     pq:P582 ?end .

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q22938576 .   # not a race (competition)
  }

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q3139516 .  # not an abbot or other church official
  }

  ?subclass rdfs:label ?subclassName .
  ?superclass rdfs:label ?superclassName .
  FILTER(LANG(?subclassName) = "en")
  FILTER(LANG(?superclassName) = "en")
}
ORDER BY ?subclassName ?start ?end

query.rq

Showing 5 of 176 rows.

subclass subclassName superclass superclassName start end
http://www.wikidata.org/entity/Q28541943 Abbasid caliph http://www.wikidata.org/entity/Q65997 caliph 0750-01-01T00:00:00Z 1258-01-01T00:00:00Z
http://www.wikidata.org/entity/Q28541943 Abbasid caliph http://www.wikidata.org/entity/Q65997 caliph 1261-01-01T00:00:00Z 1517-01-01T00:00:00Z
http://www.wikidata.org/entity/Q22120095 Academy Award for Best Costume Design, Black-and-White http://www.wikidata.org/entity/Q277536 Academy Award for Best Costume Design 1949-01-01T00:00:00Z 1957-01-01T00:00:00Z
http://www.wikidata.org/entity/Q22120095 Academy Award for Best Costume Design, Black-and-White http://www.wikidata.org/entity/Q277536 Academy Award for Best Costume Design 1960-01-01T00:00:00Z 1967-01-01T00:00:00Z
http://www.wikidata.org/entity/Q22120066 Academy Award for Best Costume Design, Color http://www.wikidata.org/entity/Q277536 Academy Award for Best Costume Design 1949-01-01T00:00:00Z 1957-01-01T00:00:00Z

results.json

{
  "@context": "https://w3id.org/ro/crate/1.2/context",
  "@graph": [
    {
      "@id": "ro-crate-metadata.json",
      "@type": "CreativeWork",
      "about": {
        "@id": "./"
      },
      "conformsTo": {
        "@id": "https://w3id.org/ro/crate/1.2"
      }
    },
    {
      "@id": "./",
      "@type": "Dataset",
      "author": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "datePublished": "2026-10-04T18:49:07.100127491+00:00",
      "description": "SPARQL retrieval materialized by Vitrify.",
      "hasPart": [
        {
          "@id": "results.json"
        },
        {
          "@id": "query.rq"
        }
      ],
      "license": "No license asserted by Vitrify; consult the source endpoint's terms of use.",
      "name": "results.json",
      "publisher": {
        "@id": "https://qlever.dev/api/wikidata"
      }
    },
    {
      "@id": "results.json",
      "@type": "File",
      "contentSize": "96502",
      "encodingFormat": "application/sparql-results+json",
      "sha256": "e17d8612c3bad3a1f4edc3a702433355e6a7c1419f2bd365b9af7bf1fdb9c647"
    },
    {
      "@id": "query.rq",
      "@type": "File",
      "contentSize": "958",
      "encodingFormat": "application/sparql-query",
      "sha256": "8221f11f3945e9b67c1252f008651615d655b7fdb2ae8a844c65214c8bf22164"
    },
    {
      "@id": "https://vitrify.iolanta.tech",
      "@type": "SoftwareApplication",
      "name": "Vitrify",
      "url": "https://vitrify.iolanta.tech",
      "version": "0.1.0"
    },
    {
      "@id": "https://qlever.dev/api/wikidata",
      "@type": "Organization"
    },
    {
      "@id": "#retrieval",
      "@type": "CreateAction",
      "agent": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "description": "HTTP 200; Accept: application/sparql-results+json",
      "endTime": "2026-10-04T18:49:07.100127491+00:00",
      "identifier": "https://qlever.dev/api/wikidata",
      "instrument": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "object": [
        {
          "@id": "https://qlever.dev/api/wikidata"
        },
        {
          "@id": "query.rq"
        }
      ],
      "result": {
        "@id": "results.json"
      },
      "startTime": "2026-10-04T18:49:04.796810417+00:00"
    }
  ]
}

ro-crate-metadata.json