ontoloji.orgOpen Reference Hub

Schema Discovery & Implicit Foreign Keys

Identifying and codifying real table relationships that lack declared database FOREIGN KEY constraints—common across mature ERP and manufacturing databases.

Why It Matters for Enterprise AI

Standard Text-to-SQL tools inspect INFORMATION_SCHEMA. In legacy ERPs where foreign keys are omitted for performance or polymorphic tables use REF_NO + DOC_TYPE, automated SQL generators fail without explicit ontology links.

Architectural Context & Execution Mechanics

Ontology discovery combines value-overlap statistics, cardinality checks, and domain-expert confirmation to record conditional cross-table and cross-system joins with auditable evidence.

Typical Production Failure Without an Ontology

An agent joins SHIPMENT.REF_NO = ORDER.ORD_NO without filtering DOC_TYPE = "SALES_SHIP", accidentally merging warehouse transfers into customer shipments.

Conditional implicit join captured in the ontology
relation Shipment -> SalesOrder {
  join: Shipment.REF_DOC == SalesOrder.ORD_NO
  when: Shipment.DOC_TYPE == "SALES_DELIVERY"
  cardinality: many_to_one
}
Related Engineering Guide

Enterprise Ontology Design Patterns for ERP, CRM & Manufacturing (MES)

Field-tested patterns for polymorphic movement tables, undeclared foreign keys, quarantine inventory, and chasm-trap prevention.

Read guide (10 min read)

Related Ontology Concepts

Open License (CC BY 4.0) · Cite This Page

Free to reference in engineering docs, ADRs, articles, and course syllabi with attribution.

[Schema Discovery & Implicit Foreign Keys — Ontoloji.org](https://ontoloji.org/en/glossary/schema-discovery-implicit-joins)