<?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 Defining Keys in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/defining-keys/m-p/63880#M32389</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a DataFrame in a Databricks notebook that I've already read and transformed using PySpark-Python. I want to create a table with defined keys (primary and foreign). What is the best method to do this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a table and directly define keys&lt;/LI&gt;&lt;LI&gt;SaveAsTable (DELTA format) and then ALTER table&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thanks, Tyas&lt;/P&gt;</description>
    <pubDate>Sat, 16 Mar 2024 05:42:01 GMT</pubDate>
    <dc:creator>tyas</dc:creator>
    <dc:date>2024-03-16T05:42:01Z</dc:date>
    <item>
      <title>Defining Keys</title>
      <link>https://community.databricks.com/t5/data-engineering/defining-keys/m-p/63880#M32389</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a DataFrame in a Databricks notebook that I've already read and transformed using PySpark-Python. I want to create a table with defined keys (primary and foreign). What is the best method to do this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a table and directly define keys&lt;/LI&gt;&lt;LI&gt;SaveAsTable (DELTA format) and then ALTER table&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thanks, Tyas&lt;/P&gt;</description>
      <pubDate>Sat, 16 Mar 2024 05:42:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/defining-keys/m-p/63880#M32389</guid>
      <dc:creator>tyas</dc:creator>
      <dc:date>2024-03-16T05:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Defining Keys</title>
      <link>https://community.databricks.com/t5/data-engineering/defining-keys/m-p/63908#M32398</link>
      <description>&lt;P&gt;Remember that keys are for information purposes (they don't validate data integrity). They are used for information in a few places (Feature tables, online tables, PowerBi modelling). The best is to define them in CREATE TABLE syntax, for example:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CREATE&lt;/SPAN&gt; &lt;SPAN&gt;TABLE&lt;/SPAN&gt; &lt;SPAN&gt;IF&lt;/SPAN&gt; &lt;SPAN&gt;NOT&lt;/SPAN&gt; &lt;SPAN&gt;EXISTS&lt;/SPAN&gt;&lt;SPAN&gt; products&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; product_id &lt;/SPAN&gt;&lt;SPAN&gt;INT&lt;/SPAN&gt; &lt;SPAN&gt;NOT NULL,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CONSTRAINT&lt;/SPAN&gt; &lt;SPAN&gt;product_id PRIMARY KEY&lt;/SPAN&gt;&lt;SPAN&gt;(product_id)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;more here &lt;A href="https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-ddl-create-table-constraint.html" target="_blank" rel="noopener"&gt;https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-ddl-create-table-constraint.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Mar 2024 20:30:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/defining-keys/m-p/63908#M32398</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2024-03-16T20:30:45Z</dc:date>
    </item>
  </channel>
</rss>

