Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/knut

.nornir/rel2graph-design.md

rel2graph — analyze a relational DB → propose/describe → transform to a graph (2026-07-26, Rickard)

Analyze a relational database, propose + describe a property-graph model for it, and (optionally) execute the transformation into a graph store (FalkorDB). Engine lives in knut (the graph/lake bridge); it's surfaced as one function in korp's Tools menu; storage in skade.

Placement (decided)

Pipeline

  1. Schema reflection — connect to the source (knut Flight SQL, or a relational connector for Postgres/MySQL/etc.) and reflect: tables, columns + types, PK, FKs, indexes, and sampled cardinality (1:1 / 1:N / M:N).

  2. Model inference (relational → property graph):

    • table → node label; row → node; PK → node identity.
    • non-FK columns → node properties (type-mapped).
    • FK → relationship (direction from cardinality; the "many" side points to the "one").
    • junction/join table (≥2 FKs, few/no other columns) → collapse to an edge (the classic M:N).
    • self-referential FK → self-loop relationship (hierarchies/trees).
    • small lookup/enum tables → optionally fold into a property or an enum label (heuristic, user-editable).
  3. Propose + describe — emit a mapping spec (relational→graph, machine-readable) + a human-readable rationale ("orders.customer_id → (:Order)-[:PLACED_BY]->(:Customer)") + a migration plan + caveats (ambiguous FKs, missing constraints, big tables).

  4. Review (korp) — render the proposed graph; let the user edit the mapping (rename labels/rels, promote/demote columns, keep/collapse a join table); re-describe on edit.

  5. Execute (optional) — run the ETL into FalkorDB via knut's existing bridge, backend-agnostic through the planned Graph trait (petgraph / FalkorDB / cozo). Idempotent; report counts.

Output EMITTERS — one analyzed model → many pipelines (Rickard)

rel2graph produces a typed mapping spec (the model), then emitters render it to executable targets — describe-first, execute-anywhere:

Symmetry with Mímir

Same pattern as Mímir, different source: Mímir analyzes CODE and models it as a graph; rel2graph analyzes a RELATIONAL DB and models it as a graph. Two instances of "analyze a structured source → propose a graph model." Reuse the backend-agnostic Graph trait as the output target.

Reuse

knut: FalkorDB client, Flight SQL, (new) relational connector. skade: schema + mapping storage. The Graph trait (planned, nornir-leaf-extraction) for backend-agnostic output. korp/facett: the graph viewer + Tools-menu host. Cozo/FalkorDB for recursive/graph queries over the result.

Status

Design capture only (fleet stays on the Tuesday korp demo). Build after the demo: start with the schema-reflection + model-inference + mapping-spec (describe-only), then the korp Tools-menu review UI, then the FalkorDB ETL execute.