Referential Integrity (Primary Key / Foreign Key Constraint) - Azure Databricks SQL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2021 07:32 AM
Hello,
Please suggest how can we implement Referential Integrity (Primary Key / Foreign Key Constraint) - between different tables defined on Azure Databricks Database.
Basically the syntax to add Primary and Foreign Key constraint in the table definitions.
Thanks in advance for your help.
Regards,
Abhishek
- Labels:
-
Databricks SQL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 12:58 PM
You can use constraints: https://docs.microsoft.com/en-us/azure/databricks/delta/delta-constraints
Stragetic Data and AI Advisor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2021 06:21 AM
according to the docs delta only has not-null and check constraints.
PK/FK constraint support is not mentioned.
Also:
https://issues.apache.org/jira/browse/SPARK-19842
So I'm afraid that it is not yet possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2022 10:55 AM
@Werner Stinckens Hii! I just posted similar question for my project..Can we do pk/fk constraints on delta tables now?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2022 11:22 PM
nothing has changed so far.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 01:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 09:31 PM
Is it sad that I was excited to see that in preview, lol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 11:12 AM
The links indicate it would be just informational, so not enforced?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 01:06 PM
If you are using Delta Live Table pipelines, the pipeline will check dependencies via the table_constraint using the primary and foreign key definitions and use that to update tables in the proper order to ensure referential integrity. So though not strongly enforced for performance reasons you still get the main benefit of keys when using pipelines. @Qi Su correct me if I'm off here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 01:13 AM
Is there any alternate way you could suggest to implement and enforce primary key constraint?

