unity-catalog-constraints

Apply Unity Catalog primary and foreign key constraints to Gold layer tables.

5|6|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/databricks-solutions/vibe-coding-workshop-template --skill unity-catalog-constraints
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-catalog-constraints
Source: https://github.com/databricks-solutions/vibe-coding-workshop-template/tree/main/data_product_accelerator/skills/common/unity-catalog-constraints
Command: npx skills add https://github.com/databricks-solutions/vibe-coding-workshop-template --skill unity-catalog-constraints

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill ensures proper relational modeling and data integrity within Unity Catalog by standardizing the implementation of Primary Key (PK) and Foreign Key (FK) constraints, preventing common deployment errors.

Core Features & Use Cases

  • Standardized Constraint Implementation: Provides patterns and scripts for defining PKs on surrogate keys and FKs referencing them, adhering to dimensional modeling best practices.
  • Production Error Prevention: Guides users to avoid critical mistakes like defining FKs inline in CREATE TABLE statements, ensuring smoother deployments.
  • Use Case: When building a Gold layer star schema, use this Skill to correctly define PKs for dimension tables (e.g., dim_store) and FKs in fact tables (e.g., fact_sales) that link back to these dimension surrogate keys, ensuring data consistency 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 by running the apply_all_constraints function.

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 and foreign key constraints to Databricks Gold layer tables?

To enforce relational integrity in Databricks Gold layer tables, use this Skill to apply ALTER TABLE statements that define surrogate keys as PRIMARY KEYS and link fact tables to dimensions via FOREIGN KEY constraints.

Why does defining foreign keys inline in CREATE TABLE cause deployment errors in Unity Catalog?

Defining foreign keys inline in CREATE TABLE statements causes deployment errors in Unity Catalog because referenced primary keys may not exist yet. This Skill prevents production errors by applying constraints via ALTER TABLE patterns after table creation.

Can I use Unity Catalog constraints for dimensional modeling in Databricks?

Yes, you can use Unity Catalog constraints for dimensional modeling in Databricks. This Skill standardizes PRIMARY KEYS on dimension surrogate keys and FOREIGN KEYS in fact tables to maintain star schema data consistency and enable BI tool discovery.

What is the best way to enforce surrogate keys as primary keys in Databricks?

The best way to enforce surrogate keys as primary keys in Databricks is by applying standardized ALTER TABLE statements. This Skill provides correct patterns to enforce NOT NULL requirements and PRIMARY KEY constraints on Gold layer dimension tables.

Do I need NOT NULL requirements on primary keys in Unity Catalog?

Yes, you need NOT NULL requirements on primary keys in Unity Catalog to ensure relational data integrity. This Skill enforces NOT NULL constraints alongside PRIMARY KEY definitions for surrogate keys to prevent null dimension references in fact tables.