Introduction to Open Data Model
The Open Data Model (ODM) is aimed at providing the infrastructure to create and query custom data model using SQL (Structured Query Language).
Native Data Hub model
Data Hub natively offers a simple relational data model
Although the native Data Hub model is enough for most of the use cases, it is quite difficult to represent custom models, among which:
- group entities by custom criterias (could be done by Forms on Site and Sources, mapping config on Variables)
- name entities according to a custom model, e.g 'source' being 'delivery point'
- add entities that do not fit well with the native model, such as 'client', 'support team', 'meter', ...
- query data according to a custom domain, e.g getting the sum of consumption of all 'consumption variables' linked to a 'delivery point'.
Moreover, using the standard Data Hub API, there is a very limited way to retrict the properties returned by the API. For example, if someone only needs the name of a source based on it's Id, the API will return all the source's properties.
Open Data Model
The ODM provides a way to synchronize SqlServer tables (called ODM tables) that will contain the corresponding DataHub entities (Site, Source or Variables). These tables will be kept in sync with operations (create/update/delete) performed in DataHub UI or API. The ODM table names are fixed and correspond to the following entities:
DataHub entity | ODM table name |
---|---|
Site | DataHubSite |
Source | DataHubSource |
Variable | DataHubVariable |
Along with the ODM tables, the customer may define custom tables and perform SQL queries, joining custom and ODM tables. This is done on a per-account basis, meaning that, most of the time, the connection string provides a SqlServer login tied to a SqlServer user being owner of a single schema.
ODM provides an API aimed at controling the ODM ecosystem.
Setting-up an ODM environment requires the following steps:
- Store a SqlServer connection string that allows ODM service to Insert/Update/Delete rows in the ODM tables.
- Define the ODM table schemas
- Create custom tables
- Init ODM tables
- Fill custom tables
- Peform queries, joining ODM tables if needed.