unity-catalog-constraints

Enforce Unity Catalog primary and foreign key constraints on Databricks Gold layer tables.

1|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/prashsub/vibe_coding_lakehouse_starter_repo --skill unity-catalog-constraints-prashsub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-catalog-constraints
Source: https://github.com/prashsub/vibe_coding_lakehouse_starter_repo/tree/main/data_product_accelerator/skills/common/unity-catalog-constraints
Command: npx skills add https://github.com/prashsub/vibe_coding_lakehouse_starter_repo --skill unity-catalog-constraints-prashsub

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill addresses the common errors and inconsistencies that arise when implementing primary and foreign key constraints in Databricks Unity Catalog for dimensional models, ensuring robust data integrity and proper relational modeling.

Core Features & Use Cases

  • Standardized Constraint Patterns: Provides clear SQL patterns for defining Primary Keys (PKs) on surrogate keys and Foreign Keys (FKs) referencing them in dimension and fact tables.
  • Production Error Prevention: Guides users to avoid critical mistakes like defining FKs inline in CREATE TABLE statements, which cause deployment failures.
  • Dimensional Modeling Best Practices: Enforces Kimball dimensional modeling principles, ensuring correct relationships between dimensions and facts.
  • Use Case: When building your Gold layer star schema, use this Skill to ensure all dimension surrogate keys are properly defined as PKs, and fact tables correctly reference these PKs via FKs, preventing deployment errors and enabling BI tool discovery.

Quick Start

Use the unity-catalog-constraints skill to apply primary and foreign key constraints to your gold layer tables.

Frequently Asked Questions about unity-catalog-constraints

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add primary key and foreign key constraints to Databricks Unity Catalog tables?

Apply primary key and foreign key constraints in Databricks Unity Catalog by using ALTER TABLE statements to define surrogate keys as PRIMARY KEYS, then adding FOREIGN KEY references to enforce dimensional modeling in your Gold layer.

Why does my foreign key constraint fail during Databricks table deployment?

Foreign key constraints fail during Databricks deployment when defined inline within CREATE TABLE statements. Prevent production errors by applying foreign key constraints separately using ALTER TABLE after creating your fact and dimension tables.

What is the best way to model surrogate keys in a Databricks Gold layer star schema?

Model surrogate keys in a Databricks Gold layer star schema by defining them as PRIMARY KEYS on dimension tables, then having fact tables reference these surrogate PKs via FOREIGN KEY constraints following standard Kimball dimensional modeling principles.

Does Unity Catalog support Kimball dimensional modeling for fact and dimension tables?

Unity Catalog supports Kimball dimensional modeling by enabling PRIMARY KEY constraints on dimension surrogate keys and FOREIGN KEY references in fact tables to maintain relational data integrity across your Gold layer.

What NOT NULL requirements are needed for primary keys in Unity Catalog?

Primary keys in Unity Catalog require NOT NULL constraints on surrogate keys to ensure valid data integrity. Enforcing these NOT NULL requirements on dimension tables is essential before applying relational constraints in your Gold layer.