SPARQL interface

This is a documentation page. Click here to go to the full documentation index.
Table of contents

A user interface for the SPARQL endpoint is available at https://cdli.mpiwg-berlin.mpg.de/resources/sparql.

Query

The interface contains three fields:

  • Endpoint sets the SPARQL endpoint used for the query.
  • Display sets the way the results of the query are displayed (see Result displays).
  • Query is the SPARQL query that will be executed (see Examples).

Additionally, the interface shows a collapsible list of prefixes. These are automatically included in the query, so instead of <http://www.cidoc-crm.org/cidoc-crm/P87_is_identified_by> you can write crm:P87_is_identified_by.

Result displays

Table

The table displays the data as-is, though URIs are prefixed. The results are not paginated, so be sure to limit your query where necessary.

Network graph

The network graph can be used to show hierarchical structures as well as other relations between data points. Regular nodes are colored in gray, blank nodes in light blue, and literal values in white.

It connects the first parameter to each of the other parameters. Optionally, text can be added to each of those links with the ?edgeLabel parameter. To display human-readable labels for nodes, include an additional parameter suffixed with Label (e.g. ?genre and ?genreLabel). URIs in nodes are strongly compacted, but the full URI is visible when hovering over a node.

Map

The map view can display coordinates and associated data on a geographical map. It takes the parameter ?geometry for GeoJSON strings. Such data is available for the following entities:

  • Collections are connected to their locations with crm:P53_has_former_or_current_location. For these locations, geo:hasCentroid is available.
  • Proveniences are connected to their locations with crm:P161_has_spatial_projection / crm:P189i_is_approximated_by and pleiades:hasLocation. For these locations, geo:hasCentroid and/or geo:hasGeometry is available.
  • Regions are themselves locaations, and have geo:hasGeometry available.

Additional fields are displayed in a popup. To display human-readable labels for nodes, include an additional parameter suffixed with Label (e.g. ?provenience and ?provenienceLabel).

Examples

Hierarchical view of genres

SELECT * WHERE {
    ?genre a cdli:terms\/type\/genre; rdfs:label ?genreLabel .
    OPTIONAL { ?genre crm:P127_has_broader_term ?parent }
}

Try it out!

Map of proveniences associated with artifacts at Harvard University

SELECT ?provenience ?provenienceLabel ?geometry (COUNT(?artifact) AS ?count) WHERE {
    VALUES ?collection { cdli:collections\/17 }
    ?artifact crm:P46i_forms_part_of ?collection ;
              crma:AP21i_is_contained_in / crma:AP5i_was_partially_or_totally_removed_by / crm:P7_took_place_at / crm:P89_falls_within ?provenience .
    ?provenience crm:P161i_is_spatial_projection_of / rdfs:label ?provenienceLabel ;
                 crm:P189i_is_approximated_by / geo:hasCentroid / geo:asGeoJSON ?geometry .
} GROUP BY ?provenience ?provenienceLabel ?geometry

Try it out!

Federated query to fetch Wikimedia Commons images associated with artifacts

SELECT ?artifact ?wikidata ?image WHERE {
  ?artifact a crm:E22_Human-Made_Object; crm:P1_is_identified_by [
    crm:P37i_was_assigned_by / crm:P14_carried_out_by cdli:external-resources\/267 ;
    crm:P190_has_symbolic_content ?wikidataUri
  ] .
  BIND(IRI(?wikidataUri) AS ?wikidata)
  SERVICE <https://query.wikidata.org/sparql> {
    ?wikidata <http://www.wikidata.org/prop/direct/P18> ?image
  }
}

Try it out!

Cite this Doc
Willighagen, Lars. 2024. “User Guides: SPARQL Interface.” Cuneiform Digital Library Initiative. November 11, 2024. https://cdli.mpiwg-berlin.mpg.de/docs/sparql-interface.
Willighagen, L. (2024, November 11). User guides: SPARQL interface. Cuneiform Digital Library Initiative. https://cdli.mpiwg-berlin.mpg.de/docs/sparql-interface
Willighagen, L. (2024) User guides: SPARQL interface, Cuneiform Digital Library Initiative. Available at: https://cdli.mpiwg-berlin.mpg.de/docs/sparql-interface (Accessed: November 11, 2024).
@misc{Willighagen2024User,
	note = {[Online; accessed 2024-11-11]},
	author = {Willighagen, Lars},
	year = {2024},
	month = {nov 11},
	title = {User guides: SPARQL interface},
	url = {https://cdli.mpiwg-berlin.mpg.de/docs/sparql-interface},
	howpublished = {https://cdli.mpiwg-berlin.mpg.de/docs/sparql-interface},
}

TY  - ELEC
AU  - Willighagen, Lars
DA  - 2024/11/11/
PY  - 2024
ID  - temp_id_126440212003
M1  - 2024/11/11/
TI  - User guides: SPARQL interface
UR  - https://cdli.mpiwg-berlin.mpg.de/docs/sparql-interface
ER  - 
This website uses essential cookies that are necessary for it to work properly. These cookies are enabled by default.