datnguye/dbterd

Optionally enforce relationship types

Closed this issue · 0 comments

Is your feature request related to a problem? Please describe.
Currently the relationship type is always assumed as one-to-many

Describe the solution you'd like
Support to detect the relationship type [one-to-many, many-to-one, one-to-one, many-to-many], based on the meta config of the test e.g.

  - name: DIM_ORDER_LINES
      - name: OL_CUSTKEY
        tests:
          - relationship:
              to: ref('DIM_CUSTOMERS')
              field: C_CUSTKEY
              meta:
                relationship_type: one-to-many

DBML Rel types:

<: one-to-many. E.g: users.id < posts.user_id
>: many-to-one. E.g: posts.user_id > users.id
-: one-to-one. E.g: users.id - user_infos.user_id
<>: many-to-many. E.g: authors.id <> books.id

Describe alternatives you've considered
Manual edit after output generated

Additional context
Enrich the ERD