英文:
Databricks enforce primary and foreign key constraints in Unity Catalog
问题
有人对Unity目录中的Databricks Delta表是否支持主键和外键约束有任何想法吗?我想在Unity中创建带有外键约束的Delta表,并需要验证放入这些表中的数据以确保一致性。截止到今天,我还没有找到任何支持文档或示例,说明如何实施这些约束,而不仅仅是声明它们以显示在表描述中。我尝试过创建带有定义约束的表,但它们不起作用。例如,使用主键约束创建的表允许在定义的列中插入重复的值。外键引用也是如此,允许插入在引用列中不存在的记录。
英文:
Does anyone have an idea about databricks delta tables in unity catalog supporting primary and foreign key constraints by enforcing them and not just declaring for informational purposes?
I'm trying to create delta tables in unity with foreign key constraints and need to validate the data put into those tables for consistency. As of today, could not find any supporting documentation or examples of this on databricks or anywhere else on how to implement these constraints and not just declare them to show on table description.
I've tried creating the tables with constraints defined but they do not work. For example, a table created with primary key constraint allow insertion of duplicate values in the defined column. Same with foreign key reference which allows insertion of records which are absent in the referencing column.
答案1
得分: 0
这个功能目前还不存在 - 正如你刚刚提到的,主键和外键目前主要用于信息目的,对于分布式/大数据系统来说是一个非常困难的问题。你可以通过实现使用Delta Live Tables实现SCD Type 1功能,在插入数据之前进行数据验证等方式来实现一些变通方法。
英文:
This functionality doesn't exist yet - as you mentioned right now primary & foreign keys are primarily for the information purpose, and it's really hard problem for distributed/big data systems. You may implement some workarounds for example by implementing SCD Type 1 functionality using Delta Live Tables, validate data before inserting, etc.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论