34 / 35 · Extensions
Anchor Modeling
Reconstruct a product from separate attributes and add a new property without changing the existing attribute tables.
The integration layer knows product 7 as the tea pack. A new source starts sending packaging material. Older records have a name and an amount, but no material. Adding a new property requires a place for the new facts and a way to keep reading products that have none.
Separate identity from each attribute#
An anchor represents the identity of a kind of object. Our product anchor contains product ID 7. An attribute table links an identity to one property. A static net amount can be stored once. A historized name can have several values with different change times. A tie links identities, as when store 11 carries product 7. A knot represents a shared set of values. Units such as grams and millilitres can be represented in a knot rather than as unconstrained text on each product. Rönnbäck et al., 2010
A new attribute attaches to the same identity
Compare the grain with Data Vault. An Anchor attribute table represents one property. A Vault satellite commonly groups attributes that come from one source or change together. Separating every property gives an independent history and schema for each, while reconstructing a wide view can require more joins. Rönnbäck and Hultgren, 2013
Read the product at a chosen time#
Treat the dates below as effective dates. Assume one value per product and effective date, and no later correction to an older date. For 4 November, the latest eligible name has the effective date of 1 November. The new material table is empty in this fixture. The outer join keeps product 7 even though it has no material row.
WITH product(product_id) AS (VALUES (7)),
product_name(product_id, valid_from, name) AS (
VALUES (7, DATE '2026-11-01', 'Tea 50 g'),
(7, DATE '2026-11-05', 'Black tea 50 g')
),
product_material(product_id, material) AS (
SELECT 7, 'paper'::text WHERE FALSE
)
SELECT p.product_id, n.name, m.material
FROM product AS p
LEFT JOIN LATERAL (
SELECT name
FROM product_name
WHERE product_id = p.product_id
AND valid_from <= DATE '2026-11-04'
ORDER BY valid_from DESC
LIMIT 1
) AS n ON TRUE
LEFT JOIN product_material AS m USING (product_id);
The result is (7, 'Tea 50 g', NULL). The lateral subquery can use the current product ID. Without the time condition, a join to both name records could return two rows for product 7. A view can present the reconstructed product with a fixed column list, and a new consumer can opt into a wider view. PostgreSQL 18, §7.2.1
The example distinguishes when a name applies from what was known at the time. To ask what the warehouse believed on 4 November about the name effective on 1 November, we also need an observation or assertion history. Separating attributes does not by itself implement that second time dimension. The semantics and keys have to specify it.
Next#
Both integration patterns reorganize data within a model. Consensus and distributed transactions returns to coordination and asks how several machines preserve one decision.
References#
- Lars Rönnbäck, Olle Regardt, Maria Bergholtz, Paul Johannesson and Petia Wohed. Anchor Modeling. Agile Information Modeling in Evolving Data Environments. Data & Knowledge Engineering, 69(12), 1229–1253, 2010. Defines anchors, attributes, ties, knots and extensions.
- Lars Rönnbäck and Hans Hultgren. Comparing Anchor Modeling with Data Vault Modeling, 2013. Compares individual attributes with grouped satellite attributes.
- PostgreSQL Global Development Group. PostgreSQL 18, Table Expressions, 2025. Specifies lateral references and outer joins.