Skip to main content

Accessing semantic data with OData web interface

Posted by: , Posted on: - Categories: Data and search, Open,, Unity without uniformity

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

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.

An example of a triple and graph made up of triples. The triple is made up of John Smith as the subject, John as the object and HasGivenName as the predicate. The graph is the different predicates: HasBirthday, HasFamilyName, WorksWith and so on
An example of a triple and graph made up of triples

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.


OData is an OASIS (the Organization for the Advancement of Structured Information Standards) standard for creating and consuming RESTful APIs.

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.

Our OData interface architecture - the ODate query is translated to a SPARQL query then our triple store (which has data from our ontology). The results are then fed into our OData interface and into any applications
Our OData interface architecture

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 OData person type showing the different Property names (PersonDateOfBirth for example) and the NavigationProperty names (PersonHasContactPoint for example)
The OData person type

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:

Following the OData specification, versatile and powerful queries can be composed.

Browsing data

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.

Types of entities in Excel showing two entities for House: House of Commons and House of Lords
Types of entities in Excel

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.

House entities in Excel: House of Commons and House of Lords
House entities in Excel

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

Sharing and comments

Share this page