Using SPIN one can parametrize a query and turn it into a web service. Or express business rules in SPARQL and execute them directly on any RDF data and models. Or define and share data quality constraints over the web.
These and many other features illustrate what we mean when we say “SPIN is SPARQL on steroids”. SPIN turns SPARQL into a complete and powerful application development tool.
What problem does SPIN address
SPIN helps users to leverage the fast performance and rich expressivity of SPARQL for various application purposes through:
- Query Templates – reusable SPARQL queries with parameters, available as web services
- Rules and Data Quality Constraints – very expressive, attached to classes in the model to drive business behavior.
- RDF syntax for SPARQL – all SPIN elements are completely declarative and stored entirely in RDF. This means that query collection can be queried, shared and discovered using the same infrastructure that also holds the data.
- Simpler, Faster, more Flexible Architecture – SPIN operates directly on RDF. Thus, there is no need to transform the data into another format in order to run rules.
- Skills Reuse – Developers don't need to learn one language for querying and another for rules
- Robust and Future-proof – based on the standard SPARQL. Encourages re-use and modularity. Entirely model-driven.
Here are just a few of the application needs addressed by SPIN Rules and Constraints:
- Dynamically calculate the value of a property based on other properties – for example, the area of a rectangle as a product of its height and width, the age of a person as a difference between today's date and person's birthday or a display name as a concatenation of the first and last names. In each case, a SPARQL query that performs the calculation is attached to a class Rectangle or a class Person.
- Check constraints and perform data validation – for example, to automatically raise inconsistency flags when currently available information does not fit the specified integrity constraints. In TopBraid EVN this is used to implement data validity checks such as a concept cannot have more than one preferred label in English (or German, French or any other language).
- Isolate a set of rules to be executed under certain conditions – for example, to support incremental reasoning, to initialize certain values when a resource is first created, or to drive interactive applications. Among many uses taking advantage of this capability is triggering email notification each time a change is made in an EVN vocabulary or ontology.
Note that SPIN is also sometimes referred to as SPARQL Rules.
SPIN describes object behavior on the web of data by combining concepts from object oriented languages, query languages, and rule-based systems. It includes the following components:
Parametrized Queries, Web Services
Rules and Constraints
SPIN Rules, SPIN Constraints attached to ontology classes
Custom Query Elements
RDF Syntax for SPARQL
SPIN queries are stored in RDF together with ontology models.
SPIN functions make it possible to re-use common SPARQL patterns. They simplify SPARQL queries and make them more maintainable.
A basic idea of SPIN is to link ontology classes with SPARQL queries that define constraints and rules formalizing the expected behavior of class members.
- Rules are implemented using SPARQL CONSTRUCT or SPARQL UPDATE requests (INSERT and DELETE). They create (infer) new information based on existing data.
- Constraints are specified using SPARQL ASK or CONSTRUCT queries. A common need in applications is to check validity of the data. For example, you may want to require that a field is entered and/or that the string entered follows your format requirements. SPIN offers a way to do constraint checking with closed world semantics and automatically raise inconsistency flags when currently available information does not fit the specified integrity constraints.
SPIN templates are parametrized queries that are available as RESTful web services. As functions, they also make it possible to re-use common SPARQL patterns.
An effective way to implement and test SPIN is to use TopBraid Composer (TBC).
- Convenient SPIN/SPARQL editors with syntax highlighting and auto-completion.
- Wizards for building reusable SPARQL queries as SPIN templates and functions.
- Built-in inference engine TopSPIN to execute SPIN rules.
- Graphical SPINMap editor for using SPIN to creating executable mappings across models
- Statistics view for understanding and tuning performance of SPIN rules.
Java programmers can create and process SPIN models with the open source TopBraid SPIN API.
TopBraid includes pre-built SPIN templates for OWL 2 RL profile and for checking data quality constraints defined in the SKOS standard. Other SPIN libraries are becoming available from SPIN users.
Learn how to use SPIN
While you can begin developing applications by reading through the technical materials listed on this site and consulting the Help facility in TopBraid Composer, for best results we recommend taking TopBraid Platform and Tools training.
- New To SPIN? SPIN in 5 Slides
- Getting Started with SPARQL Rules (SPIN)
- Inferencing and Constraint Checking (with Video)
- SPIN Constraints
- How SPIN works as an inferencing engine
- OWL-2 RL in SPARQL using SPIN
- Creating SPIN Templates in 5 Steps (PDF)
- Using the SPIN Statistics View
- SPINMap, SPARQL-based ontology mapping – Overview
- Building Web Services with the TopBraid Platform
- SPIN Vocabulary for Column Metadata
- Simplified Syntax for SPIN
- Using SPIN to Formalise Accounting Regulations (CEUR-WS.org)
- Converting the Kennedys Ontology to schema.org with SPINMap
- Currency conversion with the Units Ontology, SPARQLMotion and SPIN
- Data Quality Constraints Library
- Using SPARQL with UniProt RDF (PDF)
Specifications and Documentation
SPIN at the W3C
Using SPARQL and SPIN for Data Quality Management on the Semantic Web
SPIN in Action: Reshaping Relational Data using SPINMap