30,567
edits
Line 12: | Line 12: | ||
Prefix declarations made at the beginning of a SPARQL query tell you which namespaces (ontologies, data models, or other specifications) will be used by the query to construct its triples. Rather than having to write out a long URI every time an entity is referenced, by declaring prefixes, you can shorthand the URIs used later in the query. | Prefix declarations made at the beginning of a SPARQL query tell you which namespaces (ontologies, data models, or other specifications) will be used by the query to construct its triples. Rather than having to write out a long URI every time an entity is referenced, by declaring prefixes, you can shorthand the URIs used later in the query. | ||
For instance, instead of having to type out | For instance, by declaring the following prefixes at the beginning of the query, | ||
<syntaxhighlight lang="SPARQL"> | |||
PREFIX wd: <https://catalog.digital-scriptorium.org/entity/> | |||
PREFIX wdt: <https://catalog.digital-scriptorium.org/prop/direct/> | |||
</syntaxhighlight> | |||
instead of having to type out | |||
<br> | <br> | ||
<https://catalog.digital-scriptorium.org/entity/Q88> <https://catalog.digital-scriptorium.org/prop/direct/P16> <https://catalog.digital-scriptorium.org/entity/Q13> .</ | <syntaxhighlight lang="SPARQL"> | ||
<https://catalog.digital-scriptorium.org/entity/Q88> <https://catalog.digital-scriptorium.org/prop/direct/P16> <https://catalog.digital-scriptorium.org/entity/Q13> . | |||
</syntaxhighlight> | |||
after declaring prefixes, you can type out | after declaring prefixes, you can type out | ||
< | <syntaxhighlight lang="SPARQL"> | ||
wd:Q88 wdt:P16 wd:Q13 . | wd:Q88 wdt:P16 wd:Q13 . | ||
< | </syntaxhighlight> | ||
This makes SPARQL queries much more readable and editable by human beings. | As you can see, the Q and P values are appended to the end of the base URIs, so that you only need to know the prefix (e.g., wd, wdt) and the appropriate Q or P number to construct the triple pattern you want to use. This makes SPARQL queries much more readable and editable by human beings. | ||
==Which prefix declarations will I need to use the DS Wikibase?== | ==Which prefix declarations will I need to use the DS Wikibase?== |