query-0382435154962f8522b69f9045302bc6

rq turtle/ttl

Finding connections between celebritiesI am looking to build a query where I can show a list of well-known people (i.e. celebrities, athletes, etc) who are connected to a specific person, and then rank them by fame level (as approximated by the number of wikibase:sitelinks for a person -- although open to any alternate fame approximations). For example, if I want to list any person who has been on a project or had a professional/personal relationship with Seth Rogen (they worked together, they are friends, they are on the same board, etc), how would I do that? For the output columns, I'd like: 1) Name of celebrity 2) Link to wiki page 3) QID 4) Hometown state or country (if not in US) 19:40, 14 May 2024 (UTC)) talk (QueryBeginnerThanks in advance! .(P725)voice actor or (P161)cast member as (Q220308)Seth Rogen : The main problem where translating your question into a query is to define what "connected to a specific person" mean in terms of Wikidata claims. Here is the query with the people that have worked with QueryBeginner@

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?coworker ?coworkerLabel ?sitelinks
     WHERE {
      {
    SELECT ?work WHERE {
  {?work wdt:P161 wd:Q220308.}
  UNION
  {?work wdt:P725 wd:Q220308.}
    } }     {?work wdt:P161 ?coworker.}
     UNION
     {?work wdt:P725 ?coworker.}
     ?coworker wikibase:sitelinks ?sitelinks.
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca,en" } .
}
ORDER BY desc(?sitelinks)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?coworker"):::projected v1("?sitelinks"):::projected v2("?work") c6(["bd:serviceParam"]):::iri c8(["#91;AUTO_LANGUAGE#93;,ca,en"]):::literal c2(["wd:Q220308"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P725"--> c2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P161"--> c2 end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P725"--> v3 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P161"--> v3 end union1r <== or ==> union1l end v3 --"wikibase:sitelinks"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end