ivanshamaev/de-agent-skills/data-vault-2

Claude Code and agent skill by ivanshamaev/de-agent-skills

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when designing or implementing Data Vault 2.0 data models — Hubs, Links, Satellites, Reference Tables, Same-As Links, Multi-Active Satellites, Effectivity Satellites, Point-in-Time tables, Bridge tables, Business Vault patterns, hash key generation, DDL for all entity types, insert-only DML load patterns, pipeline architecture, and constructing Information Marts from the vault.

Install

npx vskill@latest install ivanshamaev/de-agent-skills/data-vault-2

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as ivanshamaev/de-agent-skills/data-vault-2.

Data Vault 2.0 Data Modeling

When to Use

Use this skill when:

  • Designing a Raw Vault schema: Hubs, Links, Satellites for a new source system
  • Implementing hash key generation and hash diff columns
  • Writing insert-only DML load patterns for any vault entity
  • Designing performance constructs: PIT tables and Bridge tables
  • Implementing Business Vault: computed satellites, derived links, exploration links
  • Constructing Information Mart views/tables from the vault
  • Building DV 2.0 pipelines in Spark, dbt, Airflow, or pure SQL
  • Choosing between Satellite variants: standard, multi-active, effectivity, status-tracking

Architecture Overview

Data Vault 2.0 separates concerns into three layers:

SOURCE SYSTEMS
│
▼
┌─────────────────────────────────────────────────────────┐
│ STAGING LAYER │
│ stg_<source>_<entity> — hash keys + hash diffs added │
│ load date, record source stamped │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ RAW VAULT (insert-only, no business rules) │
│ Hubs — business keys │
│ Links — relationships between hubs │
│ Satellites — descriptive attributes + history │
│ Reference tables, Same-As Links │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ BUSINESS VAULT (business rules applied) │
│ Computed Satellites — derived attributes │
│ Exploration Links — inferred relationships │
│ Same-As Links — deduplication / survivorship │
│ PIT tables + Bridge tables — query performance │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ INFORMATION MART (Kimball / flat / wide tables) │
│ Dimensional views built from vault entities │
│ Fact tables via joins through PITs + Bridges │
└─────────────────────────────────────────────────────────┘

Core DV 2.0 rules that never change:

  1. Every table has ldts (load date timestamp) and rsrc (record source)
  2. All raw vault loads are insert-only — never UPDATE or DELETE
  3. All business keys are hashed before joining or storing
  4. Business rules live in Business Vault, not Raw Vault
  5. Every Hub, Link, Satellite is loaded independently — no cross-entity transactions

Mandatory Columns on Every Table

ColumnTypeDescription
<entity>_hkchar(32) / binary(16)Hash key — MD5 of business key(s)
ldtstimestampLoad date timestamp — when this row entered the vault
rsrcvarchar(255)Record source — identifies the feeding system/file
hash_diffchar(32)Satellite-only: MD5 hash of all descriptive attributes for change detection

Hash Key Generation

Hash keys are deterministic MD5 (or SHA-256) hashes of business keys. They must be computed in staging before loading any vault table.

Rules for hash key computation
  1. Upper-case all string business keys before hashing
  2. Trim leading/trailing whitespace
  3. Use a consistent delimiter between compound key components: || (double pipe) is standard
  4. Handle NULLs by replacing with a sentinel value: '^^' (caret-caret) for null components
  5. Hash the concatenation, not individual keys
  6. Use the same algorithm everywhere in the project (MD5 is most common; SHA-256 for higher security)
sql
-- Single-component business key
md5(upper(trim(customer_id)))
-- Compound business key (order_id + line_number)
md5(concat(
upper(trim(order_id)),
'||',
coalesce(upper(trim(cast(line_number as varchar))), '^^')
))
-- Hub hash key for customer
md5(upper(trim(customer_bk)))
Hash diff for satellites

Hash diff detects whether any descriptive attribute changed — avoids loading duplicate unchanged rows.

sql
-- Hash diff: hash all satellite attributes concatenated
md5(concat_ws('||',
coalesce(upper(trim(first_name)), '^^'),
coalesce(upper(trim(last_name)), '^^'),
coalesce(upper(trim(email)), '^^'),
coalesce(upper(trim(country_code)),'^^'),
coalesce(cast(date_of_birth as varchar), '^^')
))

Order matters: always concatenate attributes in alphabetical column order so the hash is consistent regardless of SELECT column order changes.


Staging Layer

Staging transforms source data: computes all hash keys and hash diffs before any vault load.

sql
-- stg_crm_customers
create or replace view staging.stg_crm_customers as
select
-- Hash keys
md5(upper(trim(customer_id))) as customer_hk,
-- Business key (preserved as-is for Hub)
customer_id as customer_bk,
-- Satellite attributes
first_name,
last_name,
email,
country_code,
date_of_birth,
customer_segment,
-- Hash diff (alphabetical column order)
md5(concat_ws('||',
coalesce(upper(trim(cast(date_of_birth as varchar))), '^^'),
coalesce(upper(trim(customer_segment)), '^^'),
coalesce(upper(trim(country_code)), '^^'),
coalesce(upper(trim(email)), '^^'),
coalesce(upper(trim(first_name)), '^^'),
coalesce(upper(trim(last_name)), '^^')
)) as customer_sat_hashdiff,
-- Mandatory metadata
current_timestamp as ldts,
'CRM_SYSTEM_V1' as rsrc
from raw.crm_customers_landed;

If a single source load contains multiple entities (e.g. orders with embedded customer and product), create one staging view per source object — each staging view extracts the relevant fields and computes the appropriate hash keys.


Hubs

A Hub stores the master list of business keys for a business concept. Nothing else.

Rules
  • One row per unique business key — never two rows for the same key
  • No descriptive attributes (those go in Satellites)
  • Insert-only: once a business key is in the Hub, it stays forever
  • Multiple source systems feeding the same Hub use the same hash key (MD5 of the normalized business key)
DDL
sql
create table raw_vault.hub_customer (
customer_hk char(32) not null, -- MD5 hash of customer_bk
customer_bk varchar(50) not null, -- business / natural key
ldts timestamp not null, -- first time seen
rsrc varchar(255) not null, -- which source first loaded it
primary key (customer_hk)
);
create table raw_vault.hub_product (
product_hk char(32) not null,
product_bk varchar(50) not null,
ldts timestamp not null,
rsrc varchar(255) not null,
primary key (product_hk)
);
create table raw_vault.hub_order (
order_hk char(32) not null,
order_bk varchar(50) not null,
ldts timestamp not null,
rsrc varchar(255) not null,
primary key (order_hk)
);
DML — Insert-only Hub load
sql
insert into raw_vault.hub_customer (customer_hk, customer_bk, ldts, rsrc)
select
s.customer_hk,
s.customer_bk,
s.ldts,
s.rsrc
from staging.stg_crm_customers s
where not exists (
select 1 from raw_vault.hub_customer h
where h.customer_hk = s.customer_hk
);

Multi-source Hub load: when two systems both supply customers, load both into the same hub. The first system to load a key "wins" the ldts and rsrc. Subsequent loads of the same key are silently skipped.

sql
-- Merge both sources in one pass
insert into raw_vault.hub_customer (customer_hk, customer_bk, ldts, rsrc)
select customer_hk, customer_bk, ldts, rsrc
from (
select customer_hk, customer_bk, ldts, rsrc, 1 as priority
from staging.stg_crm_customers
union all
select customer_hk, customer_bk, ldts, rsrc, 2 as priority
from staging.stg_ecommerce_customers
) combined
where not exists (
select 1 from raw_vault.hub_customer h
where h.customer_hk = combined.customer_hk
)
qualify row_number() over (partition by customer_hk order by priority, ldts) = 1;

Links

A Link records a relationship between two or more Hub entities. It captures the many-to-many association at a point in time.

Rules
  • Contains only hash keys (its own + constituent Hub HKs) — no descriptive attributes
  • Insert-only: relationships are never deleted from the Link (use Effectivity Satellite to close them)
  • One row per unique combination of constituent Hub HKs
  • A Link's own hash key is the MD5 of all constituent Hub HKs concatenated
DDL
sql
-- Link: customer ↔ order (customer placed an order)
create table raw_vault.lnk_customer_order (
customer_order_hk char(32) not null, -- MD5(customer_hk || order_hk)
customer_hk char(32) not null, -- FK to hub_customer
order_hk char(32) not null, -- FK to hub_order
ldts timestamp not null,
rsrc varchar(255) not null,
primary key (customer_order_hk)
);
-- Link: order_line — connects order, product, warehouse (3-way)
create table raw_vault.lnk_order_line (
order_line_hk char(32) not null, -- MD5(order_hk || product_hk || warehouse_hk)
order_hk char(32) not null,
product_hk char(32) not null,
warehouse_hk char(32) not null,
ldts timestamp not null,
rsrc varchar(255) not null,
primary key (order_line_hk)
);
Link hash key generation (in staging)
sql
-- staging.stg_crm_orders — includes both order and customer context
md5(concat(
customer_hk, '||', order_hk
)) as customer_order_hk
-- 3-way link
md5(concat(
order_hk, '||', product_hk, '||', warehouse_hk
)) as order_line_hk
DML — Insert-only Link load
sql
insert into raw_vault.lnk_customer_order (customer_order_hk, customer_hk, order_hk, ldts, rsrc)
select
s.customer_order_hk,
s.customer_hk,
s.order_hk,
s.ldts,
s.rsrc
from staging.stg_crm_orders s
where not exists (
select 1 from raw_vault.lnk_customer_order l
where l.customer_order_hk = s.customer_order_hk
);
Non-Historized Link (Transactional Link)

For high-volume transactional data (payments, clicks, log events) where deduplication is by a natural transaction ID and there is no meaningful "relationship history" — use a Non-Historized Link (NHL). Each transaction is its own row; the natural transaction key is part of the hash.

sql
create table raw_vault.nlnk_payment_transaction (
payment_hk char(32) not null, -- MD5(payment_transaction_id)
customer_hk char(32) not null,
account_hk char(32) not null,
payment_bk varchar(50) not null, -- source transaction id (degenerate)
amount decimal(18,2) not null, -- measure stored directly (DV 2.0 allows this for transactional links)
ldts timestamp not null,
rsrc varchar(255) not null,
primary key (payment_hk)
);

Satellites

A Satellite stores descriptive attributes and their full history. Every change in a source attribute creates a new row; old rows are never updated.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ivanshamaev/de-agent-skills/data-vault-2/badge)](https://verified-skill.com/skills/ivanshamaev/de-agent-skills/data-vault-2)

Something wrong with this skill or its page? Tell us.