Concept 01
Link Anatomy & Grain
🧠 ELI5 — Explain Like I'm Five
A Link is a table that says “these two (or more) things are related.” Where a Hub says “this customer EXISTS,” a Link says “this customer PLACED this order.” Links have no descriptive data — they just record the fact that the relationship happened.
Required Columns
Every Link table in a Data Vault must contain exactly these columns — no more in the Raw Vault, no less ever:
| Column | Type | Rule |
|---|---|---|
LINK_{NAME}_HK |
CHAR(32) |
Primary Key. Hash of all participating Business Keys concatenated in a fixed order. |
HUB_{A}_HK |
CHAR(32) |
Foreign key to the first participating Hub. NOT NULL. |
HUB_{B}_HK |
CHAR(32) |
Foreign key to the second participating Hub. NOT NULL. (Repeat for each additional Hub.) |
LOAD_DATE |
TIMESTAMP |
When this relationship was first seen. Set in staging; never updated. |
RECORD_SOURCE |
VARCHAR(100) |
Which source system reported this relationship. |
The grain of a Link is the combination of all participating business keys. One unique combination = one row. A Link for “Customer placed Order” has one row per unique (CustomerID, OrderID) pair — not one row per order line item. Getting the grain wrong is the most common Link design mistake.
Two-Way Link: Customer → Order
The classic two-hub link. The hash key is derived from both business keys concatenated in a deterministic order.
-- LINK_CUSTOMER_ORDER: records the fact that a customer placed an order CREATE TABLE LINK_CUSTOMER_ORDER ( LINK_CUSTOMER_ORDER_HK CHAR(32) NOT NULL, -- MD5(CUSTOMER_BK || '||' || ORDER_BK) HUB_CUSTOMER_HK CHAR(32) NOT NULL, -- FK to HUB_CUSTOMER HUB_ORDER_HK CHAR(32) NOT NULL, -- FK to HUB_ORDER LOAD_DATE TIMESTAMP NOT NULL, RECORD_SOURCE VARCHAR(100) NOT NULL, CONSTRAINT pk_lnk_co PRIMARY KEY (LINK_CUSTOMER_ORDER_HK) );
Three-Way Link: Order → Product → Warehouse
A three-hub link works identically — just add the third FK and include the third BK in the hash. The structural pattern never changes regardless of how many hubs participate.
-- LINK_ORDER_PRODUCT: order fulfilled from a specific warehouse location -- Grain: one row per unique (OrderID, ProductID, WarehouseID) combination CREATE TABLE LINK_ORDER_PRODUCT ( LINK_ORDER_PRODUCT_HK CHAR(32) NOT NULL, -- MD5(ORDER_BK || '||' || PRODUCT_BK || '||' || WAREHOUSE_BK) HUB_ORDER_HK CHAR(32) NOT NULL, -- FK to HUB_ORDER HUB_PRODUCT_HK CHAR(32) NOT NULL, -- FK to HUB_PRODUCT HUB_WAREHOUSE_HK CHAR(32) NOT NULL, -- FK to HUB_WAREHOUSE LOAD_DATE TIMESTAMP NOT NULL, RECORD_SOURCE VARCHAR(100) NOT NULL, CONSTRAINT pk_lnk_op PRIMARY KEY (LINK_ORDER_PRODUCT_HK) );