Delta: primary keys

Laura Victoria Torres Ferrer 1 Reputation point
2022-05-19T02:33:43.693+00:00

Can primary and foreign keys be created in Delta tables? I have a relational model that I want to mount on the silver layer. From what I've read it says that delta tables on databricks don't support referencing integrity. I have tables loaded in the bronze layer in the silver layer I expected to be able to relate those tables with foreign keys and primary keys. I don't know what solution to implement.

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,534 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2022-05-23T10:03:36.927+00:00

    Hi @Laura Victoria Torres Ferrer ,

    Thank you for posting query in Microsoft Q&A Platform.

    Delta tables supports only NOT NULL and CHECK constrains. Primary key and Foreign Key constrains are not supported.

    Kindly check below documentation to understand about this more.
    https://learn.microsoft.com/en-us/azure/databricks/delta/delta-constraints

    From your ask it seems you would like relate tables between bronze layer and silver layer based on columns data. Is this for validating data? If yes, you can load data in to data frames and then perform join between data frames to see differences.

    Hope this helps. Please let us know how it goes.

    -----------------

    Please consider hitting Accept Answer button. Accepted answers help community as well.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.