Statements with Qualifiers

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):

Publication date (P577) has the property place of publication (P291) as qualifier

How can our query retrieve only the publication date in the USA?

To do this we need to understand how this data is represented.

Qualifiers explained

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:

Q17738 wdt:P57 wd:Q38222
Q17738 p:P57 Q17738-statement node
Q17738-statement node ps:P57 wd:Q38222

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:

Another exercise

| Exercise: For each of the movies in the original Star Wars trilogy (Q25540859) list the cast members (P161) and the character role (P453) they played

show solution

If you’ve learned to remove duplicates using the DISTINCT modifier, edit the query to list the unique character roles in the original Star Wars trilogy and the actors that played them.

show solution

Skip to content