Difference between revisions of "Wikidata"

From BITPlan Wiki
Jump to navigation Jump to search
Line 139: Line 139:
 
}
 
}
 
</graphviz>
 
</graphviz>
=== SPARQL Query ===
+
=== Queen Victoria's father SPARQL Query ===
 
<source lang='sparql'>
 
<source lang='sparql'>
 
# WikiData SPARQL Query
 
# WikiData SPARQL Query
Line 160: Line 160:
 
}
 
}
 
</source>
 
</source>
 +
[https://query.wikidata.org/#%23%20WikiData%20SPARQL%20Query%0A%23%0A%23%20Wolfgang%20Fahl%202018-01-06%0A%23%0A%23%20get%20father%20of%20queen%20victoria%0ASELECT%20%3FqueenVictoria%20%3FqueenVictoriaLabel%20%3FfatherProperty%20%3FfatherPropertyLabel%20%3Ffather%20%3FfatherLabel%0AWHERE%20%7B%0A%23%20%20%0A%23%20father%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP42%0A%23%20Queen%20Victoria%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FQ9439%0AVALUES%20%28%3FqueenVictoria%29%20%7B%28wd%3AQ9439%29%7D%0AVALUES%20%28%3Fproperty%29%20%7B%28wdt%3AP22%29%7D%0A%3FqueenVictoria%20%3Fproperty%20%3Ffather.%0A%3FfatherProperty%20wikibase%3AdirectClaim%20%3Fproperty%0ASERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22fr%22.%20%7D%0A%7D%0A%0A try it!]
  
 
= Import =
 
= Import =

Revision as of 11:50, 19 January 2018

The Genesis of WikiData

The Genesis of WikiData

Links

Structure

https://www.mediawiki.org/wiki/Wikibase/DataModel/Primer

Wikibase JavaScript Data Model 1.0.svg https://upload.wikimedia.org/wikipedia/commons/c/c2/Wikibase_JavaScript_Data_Model_1.0.svg

Example

Æthelstan King of the English - 927-939

Position Held


Queen Victoria

Entity:Queen Victoria

Statements
PropertyId/name value
P18/image 250px-Queen_Victoria_by_Bassano.jpg
P569/date of birth 24 May 1819
P39/position held Q9134365/Monarch of the United Kingdom qualifiers -> start:20 June 1837, end:22 January 1901, replaced by:https://www.wikidata.org/wiki/Q20875
P570/date of death 22 January 1901
P20/place of death Osborne House
P21/sex or gender] Q6581072/female

Descendants of Queen Victoria

# WikiData SPARQL Query
#
# Wolfgang Fahl 2018-01-06
#
# get childen of queen victoria
SELECT ?child ?childLabel ?genderLabel ?dob
WHERE {
#  
# child
# https://www.wikidata.org/wiki/Property:P40
# Queen Victoria
# https://www.wikidata.org/wiki/Q9439
  wd:Q9439 wdt:P40+ ?child.
# gender
# https://www.wikidata.org/wiki/Property:P21
  ?child wdt:P21 ?gender.
# date of birth
# https://www.wikidata.org/wiki/Property:P569         
  ?child wdt:P569 ?dob
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?dob

try it!

How Triples are stored in WikiData

Regular triple

WikiData Example Queen Victoria's father

WikiData Example Queen Victoria's father (technically)

WikiData Example Queen Victoria's father (multiple languages)

Queen Victoria's father SPARQL Query

# WikiData SPARQL Query
#
# Wolfgang Fahl 2018-01-06
#
# get father of queen victoria
SELECT ?queenVictoria ?queenVictoriaLabel ?fatherProperty ?fatherPropertyLabel ?father ?fatherLabel
WHERE {
#  
# father
# https://www.wikidata.org/wiki/Property:P42
# Queen Victoria
# https://www.wikidata.org/wiki/Q9439
VALUES (?queenVictoria) {(wd:Q9439)}
VALUES (?property) {(wdt:P22)}
?queenVictoria ?property ?father.
?fatherProperty wikibase:directClaim ?property
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
}

try it!

Import

Tools

What Links Here