WiliamRosa
Databricks Partner

I see your point — having the foreign key definition directly in the table schema would indeed serve as valuable documentation and improve the ability of AI assistants like Genie to reason about joins and relationships. Since DLT currently doesn’t allow self-referential constraints, one potential workaround to preserve those benefits is to maintain a “data contract” or schema definition file (YAML/JSON) that includes these logical relationships, even if they can’t be physically enforced. This file can live alongside your pipeline code, be version-controlled, and serve both as human-readable documentation and as a source for tooling/AI prompts. Another option is to create a lightweight metadata table in Unity Catalog that lists entity relationships — including self-references — so it’s queryable and can be leveraged by Genie or other assistants when generating SQL. While this doesn’t enforce the constraint in the storage layer, it still provides the semantic context you’re after.

Wiliam Rosa
Data Engineer | Machine Learning Engineer
LinkedIn: linkedin.com/in/wiliamrosa