Implementation
Persistence Engine
data are stored among 2 databases mongoDB and clickhouse:
mongoDB collections:
- resources: artefacts
- relations: relations between artefacts
- datasets: dataset definitions
- logs: sxs queries log
clickhouse tables:
- obs_${dataset._id}(_ddl): dataset's observations
- evt_${dataset._id}(_ddl): dataset's events
resources collection
- artefacts are stored after been converted to SDMX3 if required
- a resource doc is an artefact SDMX3 JSON object
- sxs just add a '_meta' tag
relations collection
- 'sourceId' and 'targetId' are '_ids' linked to resources collections
- 'version' may have a pattern (see semver)
- in case 'version' has a pattern targetId is the last match to a target
- 'itemId' is used to identify by which item the relation come from
datasets collection
observations table
Relations
relations collection describe a graph of dependencies between artefacts
collection is used each time references search params if structure queries not equals 'none'
sxs do not hardcode dependencies to return from a resourceType, but scan recursively the dependency graph dynamically
Artefact dependencies are defined in @dbmx/sdmx/types
To add a new artefact, all we have to do is to define a dedicated class with its children dependencies:
cMapping
dataset._meta.cMapping is an internal object that defined dataset's components to avoid to read DSD and so on each request and to keep track of internal implementation (dictionary)
CMapping is built at ingestion time (insert, update) from DSD grammar, so if grammar change, cMapping will not, but in a well design semVer grammar, an update that may impact CMapping must/should require a new dataset.
