<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create a Delta Table with PK and FK constraints for a streaming source data in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/create-a-delta-table-with-pk-and-fk-constraints-for-a-streaming/m-p/98349#M39703</link>
    <description>&lt;P&gt;1. How to create a Delta&amp;nbsp;Table with PK and FK constraints for a streaming source data?&lt;/P&gt;&lt;P&gt;2. When the streaming data in the silver layer gets updated, will the delta table also be updated?&lt;/P&gt;&lt;P&gt;My use case is:&lt;/P&gt;&lt;P&gt;We have a streaming data in the silver layer as SCD type 2. And we want to create a Delta Table with Primary key and foreign key constraints in the Gold Layer having SCD Type 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Nov 2024 15:30:22 GMT</pubDate>
    <dc:creator>Dharinip</dc:creator>
    <dc:date>2024-11-11T15:30:22Z</dc:date>
    <item>
      <title>Create a Delta Table with PK and FK constraints for a streaming source data</title>
      <link>https://community.databricks.com/t5/data-engineering/create-a-delta-table-with-pk-and-fk-constraints-for-a-streaming/m-p/98349#M39703</link>
      <description>&lt;P&gt;1. How to create a Delta&amp;nbsp;Table with PK and FK constraints for a streaming source data?&lt;/P&gt;&lt;P&gt;2. When the streaming data in the silver layer gets updated, will the delta table also be updated?&lt;/P&gt;&lt;P&gt;My use case is:&lt;/P&gt;&lt;P&gt;We have a streaming data in the silver layer as SCD type 2. And we want to create a Delta Table with Primary key and foreign key constraints in the Gold Layer having SCD Type 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 15:30:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-a-delta-table-with-pk-and-fk-constraints-for-a-streaming/m-p/98349#M39703</guid>
      <dc:creator>Dharinip</dc:creator>
      <dc:date>2024-11-11T15:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Delta Table with PK and FK constraints for a streaming source data</title>
      <link>https://community.databricks.com/t5/data-engineering/create-a-delta-table-with-pk-and-fk-constraints-for-a-streaming/m-p/98495#M39731</link>
      <description>&lt;P&gt;1. You can use primary key and foreign key relationships on fields in Unity Catalog tables. Primary and foreign keys are informational only and are not enforced. Foreign keys must reference a primary key in another table.&lt;/P&gt;
&lt;P&gt;You can declare primary keys and foreign keys as part of the table specification clause during table creation. This clause is not allowed during CTAS statements. You can also add constraints to existing tables.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CREATE TABLE T(pk1 INTEGER NOT NULL, pk2 INTEGER NOT NULL,
                CONSTRAINT t_pk PRIMARY KEY(pk1, pk2));
CREATE TABLE S(pk INTEGER NOT NULL PRIMARY KEY,
                fk1 INTEGER, fk2 INTEGER,
                CONSTRAINT s_t_fk FOREIGN KEY(fk1, fk2) REFERENCES T);
&lt;/LI-CODE&gt;
&lt;UL class="simple"&gt;
&lt;LI&gt;
&lt;P&gt;Primary key and foreign key constraints are available in Databricks Runtime 11.3 LTS and above, and are fully GA in Databricks Runtime 15.2 and above.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Primary key and foreign key constraints require Unity Catalog and Delta Lake.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;BR /&gt;2.&amp;nbsp;When the streaming data in the silver layer gets updated, the Delta table will also be updated. Delta Lake supports streaming reads and writes, which means that new records are processed incrementally as new table versions commit to the source table. This ensures that the Delta table reflects the latest state of the streaming data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 14:45:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-a-delta-table-with-pk-and-fk-constraints-for-a-streaming/m-p/98495#M39731</guid>
      <dc:creator>Walter_C</dc:creator>
      <dc:date>2024-11-12T14:45:39Z</dc:date>
    </item>
  </channel>
</rss>

