Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update constraints.md #6053

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions website/docs/reference/resource-properties/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ The structure of a constraint is:
- `name` (optional): Human-friendly name for this constraint. Supported by some data platforms.
- `columns` (model-level only): List of column names to apply the constraint over

When using `foreign_key`, the schema of the relation being referenced needs to be set explicitly. You can use `{{ target.schema }}` to let dbt pass the schema used by the target being used.
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

<File name='models/schema.yml'>

```yml
Expand Down Expand Up @@ -62,6 +64,8 @@ models:

</File>



## Platform-specific support

In transactional databases, it is possible to define "constraints" on the allowed values of certain columns, stricter than just the data type of those values. For example, Postgres supports and enforces all the constraints in the ANSI SQL standard (`not null`, `unique`, `primary key`, `foreign key`), plus a flexible row-level `check` constraint that evaluates to a boolean expression.
Expand Down
Loading