Advanced Metadata Structure
All items in Data Hub, whether raw, canonical, or target items, contain metadata that describes their structure. In the case of canonical and target items, the metadata also describes the transformation rules. The rules are for processing and validating the items during the composition and publication phases of the Data Hub workflow.
Canonical data is at the core of Data Hub item structure. It represents an ideal view that does not change, regardless of source or target systems.
Data Hub Metadata
Data Hub metadata is defined in XML files that are loaded at startup. When loaded, the metadata populates tables in the Data Hub database with the following kinds of metadata.
- Item Metadata - These tables contain definitions of the item categories for Raw, Canonical, and Target items.
- Attribute Model Definition - These tables contains definitions of the data fields for the data items.
- Attribute Definition - These tables contain the composition or publication transformation rules, and field mapping from one stage of the data lifecycle to the next.
Metadata is specific to not only a given domain, but also to use cases within a domain. Therefore no two systems are alike. Each system is typically a unique implementation, and specific for your project.
Metadata Structure
Though the metadata for each of the three phases of the Data Hub workflow share some similarities, there are minor differences.
Raw Item Metadata - Contains metadata for raw items and attributes used during the load phase. For example, RawItemMetadata and RawAttributeModelDefinition.
Canonical Item Metadata - Canonical metadata consists of canonical items and attributes, similar to the raw item metadata, but represents an ideal view of the data. The CanonicalAttributeDefinition contains the mapping of attributes from raw to canonical items, and is used during the composition phase.
Target Item Metadata - Contains metadata for target items and transformation rules for publication, used during the publication phase. For example, TargetItemMetadata and TargetAttributeDefinition. In addition, it contains data relating to the target system, including connection details for publication.
From XML files, the metadata is written into objects (entities), with those entities corresponding to tables in the database. The following diagram shows how each of these entities relates to the other, along with their key attributes.
The XSD file for all of the XML files mentioned in Data Hub documentation is found in the Data Hub SDK.
Constructing and Loading the Metadata
The metadata XML files are automatically loaded when Data Hub starts, as a part of your custom extension, which is located in /opt/datahub/extension-dir. In your Maven project, the default location of the metadata XML files is <project>/src/main/resources/META-INF/<your_extension>-datahub-extension.xml.
All metadata may be defined in a single XML file. We recommend that you define metadata for raw, canonical, and target items in separate XML files. Maintaining separate XML files ensures the separation of transformation rules from the canonical metadata. Such rules are dependent on either source or target systems and inhibit the independence of canonical items. The composition transformation rules (Canonical Attribute Definitions) are dependent on the source system. So, we recommend placing the rules in the raw metadata XML file. The raw metadata XML file can easily be exchanged for another when changing source systems. You can do it without having to affect the canonical metadata (the canonical view) in any way.
You may define multiple XML files using the previously mentioned naming convention. For example, you may wish to have a <your_extension-raw-> datahub-extension.xml, a <your_extension-canonical-> datahub-extension.xml and a <your_extension-target-> datahub-extension.xml.
Sample XML files can be found in the child pages outlining raw, canonical, and target metadata in more detail.