SPARQL examples

From MBI
Revision as of 13:49, 25 April 2023 by Admin (talk | contribs) (add an example with time interval for inception)

Companies

Companies with labels, inception, Postscheckkonto, Fernruf and Drahtanschrift

SELECT DISTINCT ?company ?companyLabel (year(?inc) as ?inception) ?POSTSCHECKKONTO ?FERNRUF ?DRAHTANSCHRIFT WHERE {
  ?company rdfs:label ?companyLabel;
    wdt:P3 wd:Q1.
  OPTIONAL { ?company wdt:P46 ?inc. }
  OPTIONAL { ?company wdt:P7 ?POSTSCHECKKONTO. }
  OPTIONAL { ?company wdt:P8 ?FERNRUF. }
  OPTIONAL { ?company wdt:P9 ?DRAHTANSCHRIFT. }
  FILTER((LANG(?companyLabel)) = "de")
}

Companies with labels, Inhaber, Geschäftsführer and Bankverbindungen

SELECT DISTINCT ?company ?companyLabel ?INHABER ?GESCHÄFTSFÜHRER ?BANKVERBINDUNGEN WHERE {
  ?company rdfs:label ?companyLabel;
    wdt:P3 wd:Q1.
  OPTIONAL { ?company wdt:P12 ?INHABER. }
  OPTIONAL { ?company wdt:P18 ?GESCHÄFTSFÜHRER. }
  OPTIONAL { ?company wdt:P10 ?BANKVERBINDUNGEN. }
  FILTER((LANG(?companyLabel)) = "de")
}

Companies with labels, raw texts and file segments

SELECT DISTINCT ?company ?companyLabel ?RAW_TEXT ?FILE_SEGMENT WHERE {
  ?company rdfs:label ?companyLabel;
    wdt:P3 wd:Q1;
    wdt:P4 ?RAW_TEXT;
    wdt:P5 ?FILE_SEGMENT.
  FILTER((LANG(?companyLabel)) = "de")
}

#Companies with labels, Postscheckkonto, Fernruf, Drahtanschrift and inception in time interval 1905-1910

SELECT DISTINCT ?company ?companyLabel (YEAR(?inc) AS ?inception) ?POSTSCHECKKONTO ?FERNRUF ?DRAHTANSCHRIFT WHERE {
  ?company rdfs:label ?companyLabel;
    wdt:P3 wd:Q1.
  OPTIONAL { ?company wdt:P46 ?inc. }
  FILTER(?inc >= "1905-01-01T00:00:00Z"^^xsd:dateTime)
  FILTER(?inc <= "1910-01-01T00:00:00Z"^^xsd:dateTime)
  OPTIONAL { ?company wdt:P7 ?POSTSCHECKKONTO. }
  OPTIONAL { ?company wdt:P8 ?FERNRUF. }
  OPTIONAL { ?company wdt:P9 ?DRAHTANSCHRIFT. }
  FILTER((LANG(?companyLabel)) = "de")
}

Entities

Entities with labels

SELECT DISTINCT ?entity ?entityLabel WHERE {
  ?entity rdfs:label ?entityLabel.
  FILTER((LANG(?entityLabel)) = "en")
}

Properties

Properties with labels, aliases, descriptions and datatypes

SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyAlias ?propertyDescription ?propertyType WHERE {
  ?propertyWikibase wikibase:directClaim ?p;
    wikibase:propertyType ?propertyType;
    schema:description ?propertyDescription;
    rdfs:label ?propertyLabel.
  OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
}