query-b54a6dcd52b34738b4d98cdedf03b2c0

rq turtle/ttl

Namegivers of alba amicorum of KB SELECT DISTINCT ?item ?itemLabel ?namedafter ?namedafterLabel ?owner ?ownerLabel ?dedicatedto ?dedicatedtoLabel ?nameNL ?genderLabel ?image
?commonscat (GROUP_CONCAT(DISTINCT ?dob_year ; separator = " -- ") as ?birth_year) (GROUP_CONCAT(DISTINCT ?dod_year ; separator = " -- ") as ?death_year) (GROUP_CONCAT(DISTINCT ?nta_url ; separator = " -- ") as ?nta_urls) (GROUP_CONCAT(DISTINCT ?viaf_url ; separator = " -- ") as ?viaf_urls) ?ownerofLabel ?notableworkLabel
?onfocuslistLabel ?maintainedbyLabel ?hasworksincollectionLabel ?KBcollectionItemLabel ?copyrightstatusLabel WHERE { ?item p:P31/ps:P31 wd:Q457843 . ?item p:P195/ps:P195 wd:Q1526131. # Consideration: We might want to do a UNION between ?owner, ?namedafter and ?dedicatedto, as ?owner is not always present in a Qitem ?item wdt:P138 ?namedafter. OPTIONAL {?item wdt:P127 ?owner. FILTER(?owner = ?namedafter) # The FIRST, ORGINAL owner of the album, after whom the album was named } OPTIONAL {?item wdt:P825 ?dedicatedto.} OPTIONAL {?namedafter wdt:P21 ?gender.} OPTIONAL {?namedafter wdt:P1559 ?nameNL.} FILTER(LANG(?nameNL) = "nl") . OPTIONAL {?namedafter wdt:P1006 ?nta. BIND(URI(CONCAT("http://data.bibliotheken.nl/doc/thes/p", ?nta)) as ?nta_url).} OPTIONAL {?namedafter wdt:P214 ?viaf. BIND(URI(CONCAT("https://viaf.org/viaf/", ?viaf)) as ?viaf_url).} OPTIONAL {?namedafter wdt:P18 ?image.} # Add images to items OPTIONAL {?namedafter wdt:P373 ?commonscat.} OPTIONAL {?namedafter wdt:P569 ?dob. BIND(year(?dob) as ?dob_year).} OPTIONAL {?namedafter wdt:P570 ?dod. BIND(year(?dod) as ?dod_year).} OPTIONAL {?namedafter wdt:P1830 ?ownerof. # Reverse check FILTER(?ownerof = ?item) } OPTIONAL {?namedafter wdt:P800 ?notablework. FILTER(?notablework = ?item)
} OPTIONAL {?namedafter wdt:P5008 ?onfocuslist. FILTER(?onfocuslist = wd:Q99484628)
}
OPTIONAL {?namedafter wdt:P6104 ?maintainedby. FILTER(?maintainedby = wd:Q99484628)
}
OPTIONAL {?namedafter p:P6379 ?x. ?x ps:P6379 ?hasworksincollection. FILTER(?hasworksincollection = wd:Q1526131) # only KB
?x pq:P518 ?KBcollectionItem #aplies to part = P518 FILTER(?KBcollectionItem = ?item)
} OPTIONAL {?namedafter wdt:P7763 ?copyrightstatus.}

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl". } } GROUP BY ?item ?itemLabel ?owner ?ownerLabel ?namedafter ?namedafterLabel ?dedicatedto ?dedicatedtoLabel ?genderLabel ?nameNL ?image ?commonscat ?ownerofLabel ?notableworkLabel ?onfocuslistLabel ?maintainedbyLabel ?hasworksincollectionLabel ?KBcollectionItemLabel ?copyrightstatusLabel ORDER BY ?itemLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Namegivers of alba amicorum of KB
SELECT DISTINCT 
?item ?itemLabel 
?namedafter ?namedafterLabel 
?owner ?ownerLabel 
?dedicatedto ?dedicatedtoLabel
?nameNL
?genderLabel 
?image  
?commonscat
(GROUP_CONCAT(DISTINCT ?dob_year ; separator = " -- ") as ?birth_year)
(GROUP_CONCAT(DISTINCT ?dod_year ; separator = " -- ") as ?death_year)
(GROUP_CONCAT(DISTINCT ?nta_url ; separator = " -- ") as ?nta_urls)
(GROUP_CONCAT(DISTINCT ?viaf_url ; separator = " -- ") as ?viaf_urls)
?ownerofLabel 
?notableworkLabel  
?onfocuslistLabel
?maintainedbyLabel
?hasworksincollectionLabel ?KBcollectionItemLabel
?copyrightstatusLabel
WHERE 
{
  ?item p:P31/ps:P31 wd:Q457843 .
  ?item p:P195/ps:P195 wd:Q1526131.
  # Consideration: We might want to do a UNION between ?owner, ?namedafter and ?dedicatedto, as ?owner is not always present in a Qitem
  ?item wdt:P138 ?namedafter.
  OPTIONAL {?item wdt:P127 ?owner.
           FILTER(?owner = ?namedafter) # The FIRST, ORGINAL owner of the album, after whom the album was named
           } 
  OPTIONAL {?item wdt:P825 ?dedicatedto.}
  OPTIONAL {?namedafter wdt:P21 ?gender.}
  OPTIONAL {?namedafter wdt:P1559 ?nameNL.}
           FILTER(LANG(?nameNL) = "nl") .
  OPTIONAL {?namedafter wdt:P1006 ?nta.
           BIND(URI(CONCAT("http://data.bibliotheken.nl/doc/thes/p", ?nta)) as ?nta_url).}
  OPTIONAL {?namedafter wdt:P214 ?viaf.
           BIND(URI(CONCAT("https://viaf.org/viaf/", ?viaf)) as ?viaf_url).}
  OPTIONAL {?namedafter wdt:P18 ?image.} # Add images to items
  OPTIONAL {?namedafter wdt:P373 ?commonscat.} 
  OPTIONAL {?namedafter wdt:P569 ?dob.
           BIND(year(?dob) as ?dob_year).}
  OPTIONAL {?namedafter wdt:P570 ?dod.
           BIND(year(?dod) as ?dod_year).}
  OPTIONAL {?namedafter wdt:P1830 ?ownerof. # Reverse check
           FILTER(?ownerof = ?item)
           } 
  OPTIONAL {?namedafter wdt:P800 ?notablework.
           FILTER(?notablework = ?item)         
           } 
  OPTIONAL {?namedafter wdt:P5008 ?onfocuslist.
           FILTER(?onfocuslist = wd:Q99484628)         
           }  
  OPTIONAL {?namedafter wdt:P6104 ?maintainedby.
           FILTER(?maintainedby = wd:Q99484628)         
           }  
  OPTIONAL {?namedafter p:P6379 ?x.
           ?x ps:P6379 ?hasworksincollection.
           FILTER(?hasworksincollection = wd:Q1526131) # only KB         
           ?x pq:P518 ?KBcollectionItem #aplies to part = P518
           FILTER(?KBcollectionItem = ?item)                              
           } 
  OPTIONAL {?namedafter wdt:P7763 ?copyrightstatus.}

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl". }
} 
GROUP BY ?item ?itemLabel ?owner ?ownerLabel ?namedafter ?namedafterLabel ?dedicatedto ?dedicatedtoLabel ?genderLabel ?nameNL
?image  ?commonscat ?ownerofLabel ?notableworkLabel  ?onfocuslistLabel ?maintainedbyLabel ?hasworksincollectionLabel ?KBcollectionItemLabel ?copyrightstatusLabel
ORDER BY ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?KBcollectionItem") v26("?birth_year") v19("?commonscat"):::projected v25("?copyrightstatus") v27("?death_year") v12("?dedicatedto"):::projected v20("?dob") v21("?dob_year"):::projected v22("?dod") v23("?dod_year"):::projected v13("?gender") v2("?hasworksincollection") v18("?image"):::projected v4("?item"):::projected v1("?itemLabel"):::projected v5("?maintainedby") v9("?nameNL"):::projected v11("?namedafter"):::projected v7("?notablework") v14("?nta") v15("?nta_url"):::projected v28("?nta_urls") v6("?onfocuslist") v10("?owner"):::projected v8("?ownerof") v16("?viaf") v17("?viaf_url"):::projected v29("?viaf_urls") v24("?x") a1((" ")) a2((" ")) c29(["bd:serviceParam"]):::iri c6(["wd:Q457843"]):::iri c31(["#91;AUTO_LANGUAGE#93;,nl"]):::literal c1(["wd:Q1526131"]):::iri f0[["?nameNL = 'nl'"]] f0 --> v9 v4 --"p:P31"--> a1 a1 --"p:statement/P31"--> c6 v4 --"p:P195"--> a2 a2 --"p:statement/P195"--> c1 v4 --"p:direct/P138"--> v11 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P127".-> v10 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P825".-> v12 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P21".-> v13 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P1559".-> v9 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P1006".-> v14 bind1[/"concat('http://data.bibliotheken.nl/doc/thes/p',?nta)"/] v14 --o bind1 bind1 --as--o v15 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P214".-> v16 bind2[/"concat('https://viaf.org/viaf/',?viaf)"/] v16 --o bind2 bind2 --as--o v17 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P18".-> v18 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P373".-> v19 end subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P569".-> v20 bind3[/"year-from-dateTime(?dob)"/] v20 --o bind3 bind3 --as--o v21 end subgraph optional9["(optional)"] style optional9 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P570".-> v22 bind4[/"year-from-dateTime(?dod)"/] v22 --o bind4 bind4 --as--o v23 end subgraph optional10["(optional)"] style optional10 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P1830".-> v8 end subgraph optional11["(optional)"] style optional11 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P800".-> v7 end subgraph optional12["(optional)"] style optional12 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P5008".-> v6 end subgraph optional13["(optional)"] style optional13 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P6104".-> v5 end subgraph optional14["(optional)"] style optional14 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:P6379".-> v24 v24 --"p:statement/P6379"--> v2 v24 --"p:qualifier/P518"--> v3 end subgraph optional15["(optional)"] style optional15 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:direct/P7763".-> v25 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c29 --"wikibase:language"--> c31 end bind9[/"?dob_year"/] v21 --o bind9 bind9 --as--o v26 bind10[/"?dod_year"/] v23 --o bind10 bind10 --as--o v27 bind11[/"?nta_url"/] v15 --o bind11 bind11 --as--o v28 bind12[/"?viaf_url"/] v17 --o bind12 bind12 --as--o v29