query-7b995747ffd6900baa6f9808e1dbbc4c

rq turtle/ttl

(48) Graph of shifus and parents in the legitimate family tree of xiangsheng performers: using FILTER NOT EXISTSNo.48 (2020.07.21T1017 created)

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#>
# graph of parent-child and legitimate shifu-disciple relations among xiangsheng performers by single-headed arrows 
# also viewable as table
# querying qualifiers
### Note: In comparison with the parent section "Graph of shifus and parents among xiangsheng performers: the use of UNION",
### this query, by using FILTER NOT EXISTS, gets shifu-disciple relations only in the "legitimate" family tree of xiangsheng performers,
### so that generations are not messed up (by He Yunwei).
#defaultView:Graph
SELECT DISTINCT ?xiangsheng_performer ?xiangsheng_performerLabel ?birthdate ?image ?shifu_or_parent ?shifu_or_parentLabel ?edgeLabel
WHERE {
  # define ?xiangsheng_performer as one that has teacher (P1066) or student (P802) in the shifu-disciple relationship of xiangsheng performers (Q10436443)
  # 1. ?xiangsheng_performer's "teacher" (P1066) or "student" (P802) statement is ?x1
  ?xiangsheng_performer (p:P1066|p:P802) ?x1.
  # 2. ?x1's qualifier "criterion used" (P1013) is shifu-disciple relationship of xiangsheng performers (Q10436443)
  ?x1 pq:P1013 wd:Q10436443
  # optional: show ?shifu_or_parent, which has teacher (P1066) or student (P802) in the shifu-disciple relationship of xiangsheng performers (Q10436443), same as ?xiangsheng_performer
  # 1. ?shifu_or_parent's "teacher" (P1066) or "student" (P802) statement is ?x2
  OPTIONAL { ?shifu_or_parent (p:P1066|p:P802) ?x2.
             # 2. ?x2's qualifier "criterion used" (P1013) is shifu-disciple relationship of xiangsheng performers (Q10436443)
             ?x2 pq:P1013 wd:Q10436443
             # ?shifu_or_parent is ?xiangsheng_performer's teacher (P1066) in the shifu-disciple relationship of xiangsheng performers (Q10436443)
             # 1. ?xiangsheng_performer's "teacher" (P1066) statement is ?x3
             { ?xiangsheng_performer p:P1066 ?x3.
               # 2. ?x3's value is ?shifu_or_parent
               ?x3 ps:P1066 ?shifu_or_parent;
               # 3. ?x3's qualifier "criterion used" (P1013) is shifu-disciple relationship of xiangsheng performers (Q10436443)
                   pq:P1013 wd:Q10436443
               # ?x3 should not have a qualifier "end cause" (P1534) with the value "expulsion" (Q873222)
               ### Note: 1. FILTER NOT EXISTS (replaceable by MINUS in this query) is used to remove those shifu-disciple relations that ended up in expulsion,
               ### so that this query only gets those in the "legitimate" family tree of xiangsheng performers.
               ### 2. FILTER ("values of ?x3's qualifier P1534" != Q873222) is inapplicable here
               ### because it removes not only those shifu-disciple relations that ended up in expulsion,
               ### but also those that do not have the qualifier "end cause".
               FILTER NOT EXISTS {?x3 pq:P1534 wd:Q873222}
             }
             # OR ?shifu_or_parent is ?xiangsheng_performer's father (P22) or mother (P25)
             UNION {?xiangsheng_performer (wdt:P22|wdt:P25) ?shifu_or_parent}
             # to avoid showing any other relation,
             # define ?relation as teacher (P1066) or father (P22) or mother (P25)
             VALUES ?relation {wdt:P1066 wdt:P22 wdt:P25}
             # ?relation is from ?xiangsheng_performer to ?shifu_or_parent
             ?xiangsheng_performer ?relation ?shifu_or_parent.
             # get ?relation's property label and allow it to appear on graph edge
             ?edge wikibase:directClaim ?relation;
                 a wikibase:Property}
  # optional: show ?xiangsheng_performer's birthdate (P569), which only appears in table, not graph
  OPTIONAL {?xiangsheng_performer wdt:P569 ?birthdate}
  # optional: show ?xiangsheng_performer's image (P18), which appears directly in graph, and as link in table
  OPTIONAL {?xiangsheng_performer wdt:P18 ?image}
  # show label in auto language as default, and English when no default label exists
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?birthdate"):::projected v7("?edge") v9("?image"):::projected v6("?relation") v3("?shifu_or_parent"):::projected v2("?x1") v4("?x2") v5("?x3") v1("?xiangsheng_performer"):::projected c4(["wd:Q10436443"]):::iri c12(["wikibase:Property"]):::iri c6(["wd:Q873222"]):::iri c16(["bd:serviceParam"]):::iri c18(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:P802"--> v2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:P1066"--> v2 end union0r <== or ==> union0l end v2 --"p:qualifier/P1013"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v3 -."p:P802".-> v4 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v3 --"p:P1066"--> v4 end union1r <== or ==> union1l end v4 --"p:qualifier/P1013"--> c4 subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P25"--> v3 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P22"--> v3 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P1534"--> e0c2 e0v1("?x3"):::projected e0c2(["wd:Q873222"]):::iri end f0--EXISTS--> f0e0 f0 --> v5 f0 --> c5 f0 --> c6 v5 --"p:qualifier/P1534"--> c6 v1 --"p:P1066"--> v5 v5 --"p:statement/P1066"--> v3 v5 --"p:qualifier/P1013"--> c4 end union2r <== or ==> union2l end bind1[/VALUES ?relation/] bind1-->v6 bind10(["p:direct/P1066"]) bind10 --> bind1 bind11(["p:direct/P22"]) bind11 --> bind1 bind12(["p:direct/P25"]) bind12 --> bind1 v1 -->v6--> v3 v7 --"wikibase:directClaim"--> v6 v7 --"a"--> c12 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P569".-> v8 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P18".-> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end