Source-to-domain integration

Four source schemas, one canonical commerce schema

A retailer keeps customer records, orders, fulfillment links, and product search data in different systems. Four typed mappings connect those physical schemas to one domain.

Physical source schemasEach system keeps its native shape
Typed mappingsSource fields acquire domain meaning
Canonical schemaOne model for queries and integration
01

PostgreSQL

Customer records

crm_customers(
  customer_uuid, full_name, email
)
  • customer_uuid → Customer.id
  • full_name → Customer.name
maps to Customer
02

MongoDB

Online orders

orders { orderNo, custRef,
  lines: [{ sku, qty }] }
  • orderNo → Order.number
  • lines[] → LineItem
maps to Order + LineItem
03

Neo4j

Fulfillment graph

(Order {order_no})
-[:CONTAINS {qty}]->(Product {sku})
  • order_no → Order.number
  • CONTAINS → LineItem.product
maps to Order + Product
04

Vector index

Catalog search

{ product_id, embedding,
  metadata: { sku, title } }
  • product_id → Product.id
  • metadata.sku → Product.sku
maps to Product
Commerce v1

Shared typed domain

CustomerOrderLineItemProduct
Customer.id
UUID
Order.number
Text
LineItem.qty
Integer
Product.sku
Text
Canonical query pathCustomer.orders.items.product
The mappings meet at the canonical schema. They do not require the source databases to adopt the same tables, documents, graph edges, or indexes.

What the mapping layer records

  1. Types and paths. Each source field maps to a typed domain field or relationship.
  2. Identity. Source keys remain traceable while CatDB records how they refer to canonical entities.
  3. Execution choices. A planner can federate the sources or materialize a view without moving the domain meaning into a separate pipeline.

Composition

(GF)(p)=G(F(p))(G \circ F)(p) = G(F(p))

Composed paths must remain typed. Identity and composition laws are checked at the finite semantic boundary covered by the shared fixtures.

Preservation laws

F(idA)=idF(A)F(gf)=F(g)F(f)\begin{aligned}F(\mathrm{id}_A)&=\mathrm{id}_{F(A)}\\F(g\circ f)&=F(g)\circ F(f)\end{aligned}

The Lean library checks a selected subset of path and mapping invariants. It does not verify the complete database engine.

States a mapping must expose

Total and validated

Every required source construct has a type-correct image.

Partial

Some source meaning has no declared target interpretation.

Ambiguous

More than one target interpretation remains plausible.

Lossy

The mapping discards distinctions needed for a later operation.