Wikidata:WikiProject LGBT/Queries

From Wikidata
Jump to navigation Jump to search

Home

 

Models

 

Queries

 

Members

 

About

 

Discuss

 

This is the WikiProject LGBT query collection and showcase! Present commonly requested and otherwise interesting queries here. Especially share queries which are helpful for content curation projects.

Queries for content curation[edit]

Query showcase[edit]

Politicians, born before 1910, who are LGBT+[edit]

The following query uses these:

  • Properties: sexual orientation (P91)  View with Reasonator View with SQID, sex or gender (P21)  View with Reasonator View with SQID, date of birth (P569)  View with Reasonator View with SQID, position held (P39)  View with Reasonator View with SQID, occupation (P106)  View with Reasonator View with SQID
    SELECT DISTINCT 
    ?person 
    ?label
    ?date
    WHERE {
      { ?person wdt:P91 ?orientation .} UNION {
        {VALUES ?gender {wd:Q1097630 wd:Q303479 wd:Q189125 wd:Q1052281 wd:Q2449503 wd:Q48270 #wd:Q1399232 wd:Q3277905 wd:Q746411 wd:Q350374 wd:Q660882
                        } .
        ?person wdt:P21 ?gender . }
      }
      VALUES (?earliest) {("01-01-01T00:00:00Z"^^xsd:dateTime)}
      VALUES (?latest) {("1910-01-01T00:00:00Z"^^xsd:dateTime)}
      ?person wdt:P569 ?date .
      hint:Prior hint:rangeSafe true .
      FILTER (?date >= ?earliest)
      FILTER (?date <= ?latest)
      {?person wdt:P39 ?role .} UNION { ?person wdt:P106 wd:Q82955 .}
      ?person rdfs:label ?label.
      FILTER(LANG(?label) = "en").
    
    } 
    ORDER BY DESC(?date)
    LIMIT 100
    

Academic fields sorted by the count of LGBT+ researchers publishing on the topic[edit]

SELECT DISTINCT 
?topic
?topicLabel
(group_concat(if(bound(?personName), ?personName, ?personEnglishLabel); separator=", ") as ?authors)
(COUNT(?topic) AS ?count) 
WHERE {
  {
    ?person wdt:P91 ?orientation . 
    FILTER (?orientation != wd:Q1035954 )
  } UNION {
    ?person wdt:P21 ?gender .
    VALUES ?gender { wd:Q1097630 wd:Q303479 wd:Q189125 wd:Q1052281 wd:Q2449503 wd:Q48270 wd:Q1399232 wd:Q3277905 wd:Q746411 wd:Q350374 wd:Q660882 }
  }
  ?work wdt:P50 ?person ; wdt:P921 ?topic .
  OPTIONAL {
    ?person wdt:P1559 ?personName
  }
  OPTIONAL {
    ?person rdfs:label ?personEnglishLabel
    FILTER (lang(?personEnglishLabel) = "en")
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} 
GROUP BY ?topic ?topicLabel
ORDER BY DESC(?count)
LIMIT 1000
Try it!

Same-sex couples[edit]

SELECT
?h
?hLabel
?spouse
?spouseLabel
?genderLabel
WHERE {
   ?h wdt:P21 ?gender .
   ?h wdt:P26 ?spouse .
   ?spouse wdt:P21 ?genderr .
   FILTER (?gender = ?genderr)
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
 }
LIMIT 1000
Try it!

Timeline of legalization of same-sex marriages

#defaultView:Timeline
SELECT DISTINCT ?marriage ?marriageLabel ?time ?image
{
  {
    SELECT ?marriage ?time {
      ?marriage wdt:P31|wdt:P279 wd:Q17422;
                wdt:P580 ?time.
    }
  }
  UNION {
    SELECT ?marriage ?time {
      ?marriage wdt:P31|wdt:P279 wd:Q17422;
            wdt:P585 ?time.
    }
  }
  OPTIONAL{
    ?marriage wdt:P18 ?image.
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

LGBT people born, residing, or working in New York City[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, sex or gender (P21)  View with Reasonator View with SQID, sexual orientation (P91)  View with Reasonator View with SQID, place of birth (P19)  View with Reasonator View with SQID, located in the administrative territorial entity (P131)  View with Reasonator View with SQID, residence (P551)  View with Reasonator View with SQID, work location (P937)  View with Reasonator View with SQID
    SELECT DISTINCT ?person ?personLabel ?sexualorientationLabel ?sexorgenderLabel
      WHERE {
        ?person wdt:P31 wd:Q5 . #?person is a human
        BIND(wd:Q60 as ?place). #change wd:Q60 (New York City) to whatever ?place you want to search
        
        { 
          ?person wdt:P21 ?sexorgender. #?person has ?sexorgender
          #?sexorgender is not male, female, cisgender male, cigender female, or cisgender person
          FILTER(?sexorgender NOT IN (wd:Q6581097, wd:Q6581072, wd:Q15145778, wd:Q15145779, wd:Q1093205)). 
        } UNION {
          ?person wdt:P91 ?sexualorientation . #?person has ?sexualorientation
          FILTER(?sexualorientation != wd:Q1035954). #?sexualorientation is not heterosexual
        }
        
        {
          ?person wdt:P19/wdt:P131* ?place. #?person was born in ?place
        }
        UNION {
          ?person wdt:P551/wdt:P131* ?place. #?person resides in ?place
        }
        UNION {
          ?person wdt:P937/wdt:P131* ?place. #?person works in ?place
        }
    
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
    

LGBT memorials commemorating the persecution of homosexuals in Nazi Germany and the Holocaust[edit]

The following query uses these:

  • Properties: subclass of (P279)  View with Reasonator View with SQID, image (P18)  View with Reasonator View with SQID, inception (P571)  View with Reasonator View with SQID, commemorates (P547)  View with Reasonator View with SQID
    #defaultView:Timeline
    SELECT DISTINCT ?item ?itemLabel ?image ?date WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
      {
        SELECT DISTINCT ?item WHERE {
          ?item p:P547 ?statement0.
          ?statement0 (ps:P547/(wdt:P279*)) wd:Q718858.
        }
      }
      OPTIONAL { ?item wdt:P18 ?image. }
      OPTIONAL { ?item wdt:P571 ?date. }
    }
    

LGBT historic places[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, coordinate location (P625)  View with Reasonator View with SQID, inception (P571)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID, commemorates (P547)  View with Reasonator View with SQID
    SELECT ?item ?itemLabel ?geo ?inception ?countryLabel ?commemorates ?commemoratesLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
      ?item wdt:P31 wd:Q29469577.
      OPTIONAL { ?item wdt:P625 ?geo. }
      OPTIONAL { ?item wdt:P571 ?inception. }
      OPTIONAL { ?item wdt:P17 ?country. }
      OPTIONAL { ?item wdt:P547 ?commemorates. }
    }
    

LGBT choires around the world[edit]

The following query uses these:

Queries for data-model maintenance[edit]

Statement-required constraints involving properties related to gender[edit]

#defaultView:Tree
select ?reqPropKind ?reqPropKindDesc ?reqProp ?reqPropDesc ?constraintStatus ?constraintStatusDesc ?prop ?propDesc {
  ?reqPropKind wdt:P279* wd:Q107417492.
  ?reqProp wdt:P31 ?reqPropKind.
  ?prop p:P2302 [
    ps:P2302 wd:Q21503247;
    pq:P2306 ?reqProp;
    pq:P2316 ?constraintStatus;
  ].
  
  ?reqPropKind rdfs:label ?reqPropKindLabel.
  FILTER(lang(?reqPropKindLabel) = "en")
  
  ?reqProp rdfs:label ?reqPropLabel.
  FILTER(lang(?reqPropLabel) = "en")
  
  ?constraintStatus rdfs:label ?constraintStatusLabel.
  FILTER(lang(?constraintStatusLabel) = "en")
  BIND(
    IF(?constraintStatus = <http://www.wikidata.org/entity/Q62026391>, "is suggested to be used", 
      IF(?constraintStatus = <http://www.wikidata.org/entity/Q21502408>, "is mandated to be used",
        "is implied in a constraint that applies"
      )
    )
    AS ?constraintStatusPhraseStr
  )
  
  ?prop rdfs:label ?propLabel.
  FILTER(lang(?propLabel) = "en")

  BIND(CONCAT("Property of kind “", ?reqPropKindLabel, "”, namely …") as ?reqPropKindDesc)
  BIND(CONCAT("“", ?reqPropLabel, "” (", str(?reqProp), "), …") as ?reqPropDesc)
  BIND(CONCAT(?constraintStatusPhraseStr, " (", str(?constraintStatus), ") on items that have property …") as ?constraintStatusDesc)
  BIND(CONCAT("“", ?propLabel, "” (", str(?prop), ").") as ?propDesc)
}
Try it!