Query statements with Qualifiers
Many statements in Wikidata are not just simple triplets in the form of Item-Property-Value, but may also include a qualifier. Qualifiers allow statements to be expanded on, annotated, or contextualized beyond what can be expressed in just a simple property-value pair. Qualifiers are used in order to further describe or refine the value of a property given in a statement. Note that a statement should still provide useful data even without a qualifier; the qualifier is just there to provide additional information.
Take for example the property “publication date” (P577). The following query retrieves the publication date for each of the films in the Star Wars series:
Although there are 9 films in the series, we get 32 results. Why?
As we have seen before, a property can have multiple values. In this case, there are several values for “publication date” per film. Why? Because there are different release dates for different countries. For each value there is a qualifier indicating the property “place of publication“ (P291) and its value. For example, for the item Star Wars Episode IV: A New Hope (Q17738):
How can our query retrieve only the publication date in the USA?
To do this we need to understand how this data is represented.
Until now we had statements such as:
This link between the item and its value is a “direct property”. In our queries we referred to it with the prefix wdt.
In the Wikidata data model, for every direct property linking an item and a value, there is also a simple property (p) that connects the item to a statement node. That statement node is then linked to the value of the direct property by a property statement (ps), as shown in this graphic view:
Another way of describing this data is through statements:
In the last row, the statement node serves as the “Item” in an Item-Property-Value statement.
Statements that have a qualifier have an additional link from the statement node – a property qualifier (pq) – as shown in the following diagram:
We can now formulate a query to get the publication date (P577) of the films in the Star Wars series if the place of publication (P291) is the USA: