Our triple store, also called a graph database, is an important component of our new data service for Parliament. The triple store provides semantic representation of structured data, and is more flexible for describing graph structures than traditional databases such as relational databases. So we've just launched our powerful web interface to help users and applications access and query our semantic data in a triple store.
The web interface is based on a standardised protocol called OData. Schema of the interface is generated from the ontology describing the semantic data. An example of this is 'query all Houses in Parliament'.
For developers, the source code of our interface is on GitHub.
Triple store data are in forms of triples, each of which consists of a subject, a predicate, and an object. These triples are linked to each other to form graphs. An example is shown below. These graphs can represent real world relationships between different types of entities. Triple stores help realisation of linked data and the semantic web.
The schema of triple data is normally specified by an ontology, such as our ontology. An ontology describes the relationships between different types of entities. Example types in our ontology include Member of Parliament, Parliamentary House, and formal body.
For a triple store with many triples, a powerful query language called SPARQL is used for Create, Read, Update, and Delete (CRUD) operations on the data.
However SPARQL is not intended as a RESTful protocol, and writing SPARQL queries normally needs some training. Therefore we developed an OData interface to help applications and users access our triple store.
An OData interface is easy to consume by both users and applications. OData metadata is a machine-readable description of the data model, and allows the creation of generic client applications. There's an existing ecosystem of applications based on OData, such as LINQpad for building OData queries interactively, Power Query for Excel and Power BI for simplifying data discovery, access, and collaboration, and Tableau.
Our interface combines the data management strengths of a triple store with the application development strengths of OData.
Our OData interface
OData is an abstract interface to any type of data stores. Developers can build an OData interface based on any kind of data store, in our case, a triple store. Our interface architecture is shown below.
The ontology file describing the triple store data is used to generate C# class hierarchy as an assembly file. The assembly is used by the OData interface to build the OData metadata model. This is done at the development stage.
When a user or application consumes our interface, they first send an OData query to our interface. The interface translates the OData query to a SPARQL query, and sends the query to the triple store. The triple store returns query results, and the interface converts the query results to OData query results to be returned to the user or application.
The OData metadata lists the types of entities and their properties. Each type has a primary key property. Types can link to each other through navigation properties. One example is below.
The Person type has an Id primary key, five properties such as PersonDateofBirth, and five navigation properties such as PersonHasPersonImage linking Person type to PersonImage type.
The OData metadata is used as the guidance for composing OData queries. These queries follow the OData Version 4.0 specification. Some example query URLs are below. This is the service root URL and all query URLs have the root as a prefix. Here's some examples of queries:
- query all Houses
- return only House names
- expand House entities with a navigation property
- query House by primary key
- find a House by primary key, then find the top 2 House seats for the House
- count the number of House seats for a House
- expand a House entity with formal body entities and order these formal body entities by their names, pick the top two, and return only their names and Ids
Following the OData specification, versatile and powerful queries can be composed.
Microsoft Excel can access the OData service via Power Query, in the same way that Power BI can access the OData service. Excel can use the metadata of the interface to find entity types, and allow users to navigate through properties and navigation properties of these types in a tabular form without writing any queries. The image below shows the list of types in Excel for our interface.
When House type is selected, all House entities and their properties are shown in a table. When a user opens the House table, the Houses with their properties and navigation properties are shown. The navigation properties are tables of values, which can be clicked on for further navigation as shown below.
Flexible and friendly interface
OData allows not only Read access, but also Create, Update, and Delete operations on the underlying data store. Our OData interface provides a flexible and friendly interface for users and applications to access and maintain a triple store. Developers can find out more about our work using the GitHub source code.
Tweet our boss Dan and let us know if you’re using our data. We’d love to hear about it.
Read more about the work of the data and search team.