Skip to content

Commit

Permalink
Update constraints.md (#4986)
Browse files Browse the repository at this point in the history
adding multi column foreign key example per partner feedback and raised
by @sdurry .
  • Loading branch information
mirnawong1 authored Feb 26, 2024
2 parents d05466d + 235e003 commit 04ae1e9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions website/docs/reference/resource-properties/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ models:
constraints:
- type: primary_key
columns: [<first_column>, <second_column>, ...]
type: foreign_key # multi_column
columns: [<first_column>, <second_column>, ...]
expression: "<other_model_schema>.<other_model_name> (<other_model_first_column>, <other_model_second_column>, ...)"
- type: check
columns: [<first_column>, <second_column>, ...]
expression: "<first_column> != <second_column>"
Expand Down Expand Up @@ -224,7 +227,7 @@ select
- Snowflake constraints documentation: [here](https://docs.snowflake.com/en/sql-reference/constraints-overview.html)
- Snowflake data types: [here](https://docs.snowflake.com/en/sql-reference/intro-summary-data-types.html)

Snowflake suppports four types of constraints: `unique`, `not null`, `primary key` and `foreign key`.
Snowflake suppports four types of constraints: `unique`, `not null`, `primary key`, and `foreign key`.

It is important to note that only the `not null` (and the `not null` property of `primary key`) are actually checked today.
The rest of the constraints are purely metadata, not verified when inserting data.
Expand Down Expand Up @@ -434,7 +437,7 @@ Databricks allows you to define:
- a `not null` constraint
- and/or additional `check` constraints, with conditional expressions including one or more columns

As Databricks does not support transactions nor allows using `create or replace table` with a column schema, the table is first created without a schema and `alter` statements are then executed to add the different constraints.
As Databricks does not support transactions nor allows using `create or replace table` with a column schema, the table is first created without a schema, and `alter` statements are then executed to add the different constraints.

This means that:

Expand Down

0 comments on commit 04ae1e9

Please sign in to comment.