Wikidata Prefix System
Wikidata writes the same property Pxxx with different prefixes (wdt:, p:, ps:, pq:) depending on whether the triple skips the statement node, leads to it, or leads from it to the main value or to a qualifier; entities use wd:.
Properties#
wdt:P166,p:P166,ps:P166,pq:P166are technically different IRIs; the common suffixP166says that they express the same relation.- Path structure:
entity ──p:Pxxx──▶ statement node ──ps:Pxxx──▶ value ──pq:Pyyy──▶ qualifier value
When to use which:
| Need | Use |
|---|---|
| reference a known entity | wd:Qxxx |
| simple property value, no qualifiers | wdt:Pxxx |
| value with qualifiers (year, for work, start time, …) | p:Pxxx → ps:Pxxx + pq:Pyyy |
| filter by type (“instance of”) | wdt:P31 on the value, not on the statement node |
| English name | rdfs:label + FILTER (LANG(?x) = "en") |
Example#
Which Oscars did Meryl Streep win, and for which movies?
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?movie ?award WHERE {
wd:Q873 p:P166 ?mediator . # Meryl Streep → award statement node
?mediator ps:P166 ?award_id . # which award
?mediator pq:P1686 ?movie_id . # qualifier: for work
?award_id wdt:P31 wd:Q19020 . # award is an instance of Academy Award
?award_id rdfs:label ?award . FILTER (LANG(?award) = "en")
?movie_id rdfs:label ?movie . FILTER (LANG(?movie) = "en")
}
p:P166 “won award” (awardee → statement node), ps:P166 “won award” (statement node → award), pq:P1686 “for work” (statement node → movie), wdt:P31 “instance of” (instance → class).
Sources#
- Slides 07, p. 10 (Wikidata IRIs and prefixes), p. 21 (statement nodes), p. 22 (naming scheme), pp. 23–25 (Meryl Streep query)
- DBIS_VL07 > Wikidata’s naming scheme, DBIS_VL07 > Finding the right query is hard
- Exams: DBIS Exam WS2324 (not published) (Task 3.2), DBIS Exam WS2324-2 (not published) (Task 3.2)