One of the more technical skills that taxonomists may be asked to have is knowing how to construct SPARQL queries. As the QL at the end of the name suggests, SPARQL is a kind of query language, like SQL. But unlike SQL, which is for querying data in traditional relational databases, SPARQL is for querying data in graph databases, specifically RDF triple-store graph databases, upon which taxonomies are typically based.
SPARQL is especially useful for getting information out of ontologies and knowledge graphs, and this it is used more by ontologists than by taxonomists. Querying a taxonomy is still very valuable, though, particularly in later stages of developing a taxonomy or in maintaining and updating a taxonomy. As a taxonomy consultant, I have spent more time, however, in the initial development of taxonomies, so I did not have as much opportunity to use SPARQL. I attended SPARQL workshops at the Connected Data London Conference in 2024 and the Knowledge Graph conference this May 2026. However, these workshops, after teaching the basics, quickly moved on to examples of querying specific medical or financial data in knowledge graphs, which is not my area of interest.
I was seeking instruction focused on querying and improving taxonomies but did not find that. So, I teamed up with ontologist Lisa Dawn Colvin, who was also at the Knowledge Graph Conference in May, to give a presentation at the Taxonomy Boot Camp conference this month called “SPARQL Field Guide for Taxonomists.”
For the presentation, I came up with example taxonomy query scenarios, and Lisa created the example queries for those scenarios, after presenting some basics on SPARQL. Actually, I didn’t come up with all of the SPARQL use cases myself. Asking on discussion groups, I got some input from other SPARQL-using taxonomists for some additional SPARQL use cases.
What is SPARQL and how does it work?
SPARQL stands for SPARQL Protocol and RDF Query Language. RDF (Resource Description Framework) is a foundational data model for linked data on the web, which was development as a recommendation by the World Wide Web Consortium. In RDF, all resources are defined by URIs (Uniform Resource Identifiers) or IRIs (Internationalized Resource Identifiers), which are similar to URLs, and all data is modeled in triples of subject-predicate-object. Triples connect to each other to form larger graphs, which are a feature of graph databases. SPARQL allows you to ask about variables in triples, while setting parameters and restrictions.
SPARQL is used to query not just RDF data, but any data model that is based on RDF. That includes RDFS and OWL, used in ontologies, and SKOS (Simple Knowledge Organization System), used in taxonomies and thesauri. All of these data models and SPARQL are considered part of the “Semantic Web stack” of technologies. I explained SKOS in a prior blog post SKOS Taxonomies.
SPARQL is used to extract information from a graph, typically as a report in a table format, and it may also used to edit the graph, especially in making batch edits to certain properties. There are various scenarios for getting reports from taxonomies in order to improve and maintain them. These include counts, listing concepts with certain missing properties, and listing concepts that have certain properties to check that they are correct. These properties may be alternative labels, definitions, text strings within labels, and having certain relationships, such as having more than one broader relationship. Batch edits could be for adding or changing a text string to labels, adding linked relations, or deleting values in a specific attribute field, and these changes would be made across multiple concepts meeting certain criteria.
SPARQL and taxonomy management software
When I first started using taxonomy/thesaurus management software, SKOS (published in 2009) was not yet a standard. However, the pre-SKOS taxonomy/thesaurus management systems I used had reporting features that were highly customizable. Later, when I started using SKOS-based taxonomy/ontology management software PoolParty, I was disappointed with the relative lack of customized reporting in the user interface. Taxonomy management software products vary to the degree the allow customization of reports. I was told to just use SPARQL instead. Dedicated software for taxonomy management (along with thesaurus and ontology management today is based on SKOS and allows users to enter their SPARQL queries in a space often called a “SPARQL endpoint.”
The editing capability of SPARQL allows you to make multiple changes to a taxonomy more efficiently than through the user interface of taxonomy management software, in which changes must be made one-by-one. You can also make batch changes to the taxonomy if you change your mind on the taxonomy’s characteristics, such as its capitalization style, adherence to quality rules (such as no duplicate labels), or the URI patterns for resources. To prevent undesired changes to the taxonomy, however, SPARQL editing commands are typically not entered through the same SPARQL endpoint as reporting commands.
Generating SPARQL with AI
Of course, you can use generative AI/LLMs to create correctly functioning SPARQL queries. I used ChatGPT and Claude to create queries that my colleague Lisa had done by hand. Her reports were cleaner and thus better for sharing. What’s nice is that the LLMs tend to give more than one SPARQL query per prompt request and provide explanations. It’s good to have some understanding of SPARQL, so you know what it can do for your taxonomy, how to write good prompts and, how to understand the results, and know what might need to be changed in the query. With AI-generated queries, SPARQL is now more accessible to those taxonomists who use it less frequently and don’t spend the time to master the skill.
Learn more from the conference presentation slides that Lisa Dawn Colvin and I created for Taxonomy Boot Camp.

No comments:
Post a Comment