Skip to content

Constraint application of primary and foreign keys #47

Description

@matinnuhamunada

Hi, I'm quite new to DBT and DuckDB. I'm still a bit confused about setting up primary and foreign keys in the models.

I saw that this is how it is being implemented in the models:

- name: order_id
tests:
- unique
- not_null
description: This is a unique identifier for an order
- name: customer_id
description: Foreign key to the customers table
tests:
- not_null
- relationships:
to: ref('customers')
field: customer_id

When I open the resulting .db file in DBeaver or Metabase, the constraints doesn't seem to be implemented.

My question is:

  • Is this something that is expected in DBT or am I missing something?
  • Why don't we implement this in the .sql scripts?

PS:
I also found these tools:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions