Open main menu

Property talk:P4316

Contents

Documentation

kinship equivalent in SPARQL at Wikidata
part of a SPARQL query that lists this type of ?relative of a ?person. Use with relationship properties (except P1038). See instructions for applicable format.
Data typeString
Domainkinship (Q171318)
Allowed values(?i)((?!\bP1038).)*.*\?person.*.*\?relative.*(?i)((?!\b(,|;)).)*
Usage notesSPARQL query without SELECT * {}, wdt:P31 wd:Q5, but always including ?person and ?relative. Relationship properties: P22, P25, P40, P26, P3373 (add more if needed, not P1038)
Examplefather (Q7565)?person wdt:P22 ?relative
paternal grandmother (Q12714606)?person wdt:P22/wdt:P25 ?relative
Formatter URLhttps://query.wikidata.org/#SELECT%20%3Fperson%20%3FpersonLabel%20%3Frelative%20%3FrelativeLabel%0A%7B%20%0A%20%20$1.%0A%20%20%3Fperson%20wdt%3AP31%20wd%3AQ5%20.%20%3Frelative%20wdt%3AP31%20wd%3AQ5%20.%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D%0ALIMIT%2010
https://query.wikidata.org/#SELECT%20%0A%20%20%28COUNT%28%2a%29%20as%20%3Fct1%29%20%0A%20%20%28COUNT%28DISTINCT%20%3Fperson%29%20as%20%3Fct2%29%20%0A%20%20%28COUNT%28DISTINCT%20%3Frelative%29%20as%20%3Fct3%29%20%0AWHERE%0A%7B%20%20%0A%20%20%20%20$1%20.%20%0A%20%20%20%20%3Fperson%20wdt%3AP31%20wd%3AQ5%20.%20%0A%20%20%20%20%3Frelative%20wdt%3AP31%20wd%3AQ5%0A%7D
Lists
Proposal discussionProposal discussion
Current uses135
  Type “kinship (Q171318): element must contain property “instance of (P31)” with classes “kinship (Q171318)” or their subclasses (defined using subclass of (P279)). (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P4316#type Q171318, SPARQL, SPARQL (new)
  Format “(?i)((?!\bP1038).)*: value must be formatted using this pattern (PCRE syntax). (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P4316#Format, SPARQL, SPARQL (new)
  Format “.*\?person.*: value must be formatted using this pattern (PCRE syntax). (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P4316#Format, SPARQL, SPARQL (new)
  Format “.*\?relative.*: value must be formatted using this pattern (PCRE syntax). (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P4316#Format, SPARQL, SPARQL (new)
  Format “(?i)((?!\b(,|;)).)*: value must be formatted using this pattern (PCRE syntax). (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P4316#Format, SPARQL, SPARQL (new)
  Item “opposite of (P461): Items with this property should also have “opposite of (P461)”. (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P4316#Item P461, search, SPARQL, SPARQL (new)
  Distinct values: this property likely contains a value that is different from all other items. (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P4316#Unique value, SPARQL (every item), SPARQL (by value), SPARQL (new)
  Scope is as main value (Q54828448): the property must be used by specified way only (Help)
List of this constraint violations: Database reports/Constraint violations/P4316#scope, hourly updated report, SPARQL, SPARQL (new)
  Pattern ^(.*) ([)/<> |].*)$ will be automatically replaced to \1\2.
Testing: TODO list

  Pattern ^(.*[(/<> |]) (.*)$ will be automatically replaced to \1\2.
Testing: TODO list

  Pattern ^(.+[^ ])\.(.+)$ will be automatically replaced to \1 .\2.
Testing: TODO list

Sample queryEdit

#Relatives of Q9682
#Added 2017-10-10 by Jura1
SELECT (
  IRI(
    CONCAT(
        "https://query.wikidata.org/#",
        "SELECT DISTINCT ?kinship ?relative ?relativeLabel ",
        "WHERE ",
        "{ ",
        " BIND( wd:Q9682 as ?person) " , 
        GROUP_CONCAT(?sparql1; separator=" UNION "), 
        " SERVICE wikibase:label { bd:serviceParam wikibase:language 'en'. ?relative rdfs:label ?relativeLabel } ",
        "} "  ) 
    )
  as ?sparql)  
WHERE
{
    SELECT ( CONCAT( "{", str(?value), ' . BIND("', str(?itemLabel), '" as ?kinship)} ' ) as ?sparql1) 
    {
        ?item wdt:P4316 ?value
        SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?item rdfs:label ?itemLabel  }          
    }
    LIMIT 100
}
LIMIT 1000

Try it!

Sample query 2Edit

#Ancestors of US Presidents
#Added 2017-10-21 by Jura1
SELECT (
  IRI(
    CONCAT(
        "https://query.wikidata.org/#",
        "SELECT DISTINCT ?person ?personLabel ?ord ?kinship ?relative ?relativeLabel ",
        "WHERE ",
        "{ ",
        " ?person wdt:P39 wd:Q11696 ; wdt:P31 wd:Q5 " , 
        GROUP_CONCAT(?sparql1; separator=" UNION "), 
        " SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } ",
        "} ",
        "ORDER BY ?personLabel ?ord "  ) 
    )
  as ?sparql)  
WHERE
{
    SELECT ( CONCAT( "{", str(?value), ' . BIND(', str(?ord), ' as ?ord) . BIND("', str(?itemLabel), '" as ?kinship)} ' ) as ?sparql1) 
    {
        ?item wdt:P4316 ?value ; p:P179 [ ps:P179 wd:Q267388 ;  pq:P1545 ?ord ]
        SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?item rdfs:label ?itemLabel  }          
    }
}
LIMIT 1000

Try it!

Sample query 3Edit

#Chinese family relationship terms
#Added 2017-10-22 by Jura1
SELECT (
  IRI(
    CONCAT(
        "https://query.wikidata.org/#",
        "SELECT DISTINCT ?person ?personLabel ?kinship ?kinshipLabel ?kinshipDescription ?relative ?relativeLabel ",
        "WHERE ",
        "{ ",
        " { ?person wdt:P27 wd:Q148 } UNION { ?person wdt:P27 wd:Q29520 } UNION { ?person wdt:P27 wd:Q865 } . ?person wdt:P31 wd:Q5 " , 
        GROUP_CONCAT(?sparql1; separator=" UNION "), 
        " SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE],en' } ",
        "} ",
        "ORDER BY ?personLabel ?kinshipLabel "  ) 
    )
  as ?sparql)  
WHERE
{
    SELECT ( CONCAT( "{", str(?value), ' . BIND(IRI("', str(?item), '") as ?kinship)} ' ) as ?sparql1) 
    {
        ?item wdt:P4316 ?value ; wdt:P31 wd:Q42301475
        SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?item rdfs:label ?itemLabel  }          
    }
}
LIMIT 1000

Try it!

To doEdit

property values:

  • maybe change wdt:P26 to p:P26/ps:P26
  • normalize space around "/" and "|" and "."
  • replace "," or ";" in syntax
  • add complex constraints based values for qualifier "criterion used" on "opposite of"-statements
  • maybe replace named variables with "/" when not needed

other:

DiscussionEdit

Return to "P4316" page.