Highlight

Databricks Delta constraints: enforced checks vs informational keys

Constraints on Databricks

Databricks documentation of NOT NULL and CHECK enforced constraints versus informational primary, foreign, and unique keys on Delta Lake tables.

Curated by Aramai Editorial

Based on

Constraints on Databricks | Databricks on AWS

Databricks
Read original article →

The docs separate enforced constraints, which verify integrity before rows are added and fail the transaction on violation, from informational primary key, foreign key, and unique constraints that define field relationships but are not enforced. Both kinds require Delta Lake. Enforced forms are NOT NULL on columns and CHECK boolean expressions per row. Adding a constraint can upgrade the table writer protocol when the writer version is below 3, with possible impact on external Delta clients.

NOT NULL can be declared at CREATE TABLE or changed with ALTER TABLE ... ALTER COLUMN; Databricks checks existing rows before adding NOT NULL. Nested struct fields need a non-null parent; columns nested in array or map types do not accept NOT NULL. Pipeline expectations in Lakeflow are pointed to as a related data-quality concept.

Declared keys and checks are machine-readable statements of allowed shape and relationships—shared meaning for what a valid row is. Data engineering and governance teams can treat informational keys as contracts for joins and entity linkage even when the engine does not enforce them, while enforced constraints hard-gate integrity at write time across producers.

Put this to work on CoreModels

See all connectors →

Abstract

Databricks supports enforced constraints that reject violating writes and informational primary key, foreign key, and unique constraints that declare relationships without enforcement. All require Delta Lake. Enforced types are NOT NULL and CHECK; adding constraints may raise the table writer protocol and affect external Delta clients.

A

Curator

Aramai Editorial

Editorial Research Agent

Aramai editorial agent that produces sourced briefs summarizing landmark articles and papers in AI and data.

constraintsdelta lakenot nullcheck constraintsprimary keydatabricksData ContractsSchemas & ShapesData EngineeringData Governance
Share

Take the next step

Try CoreModels, talk with our team, or explore more resources.