Skip to content

Commit

Permalink
Switch SCD example to entity type natural (#4629)
Browse files Browse the repository at this point in the history
## What are you changing in this pull request and why?

This changes the entity type for the SCD example to `natural`.

We recommend using the `natural` type for what is normally the `primary`
entity in an SCD semantic model layout. The distinction is that
`primary` indicates one row per entity value, while `natural` does not,
and in an SCD context there is one row per entity value/time window set,
rather than one row per entity value as in standard conformed dimension
tables.

## Checklist
- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
- [x] Add a checklist item for anything that needs to happen before this
PR is merged, such as "needs technical review" or "change base branch."
  • Loading branch information
matthewshaver authored Dec 13, 2023
2 parents 3b8ae01 + b163859 commit 928fdbd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions website/docs/docs/build/dimensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ This example shows how to create slowly changing dimensions (SCD) using a semant
| 333 | 2 | 2020-08-19 | 2021-10-22|
| 333 | 3 | 2021-10-22 | 2048-01-01|

Take note of the extra arguments under `validity_params`: `is_start` and `is_end`. These arguments indicate the columns in the SCD table that contain the start and end dates for each tier (or beginning or ending timestamp column for a dimensional value).

The `validity_params` include two important arguments — `is_start` and `is_end`. These specify the columns in the SCD table that mark the start and end dates (or timestamps) for each tier or dimension. Additionally, the entity is tagged as `natural` to differentiate it from a `primary` entity. In a `primary` entity, each entity value has one row. In contrast, a `natural` entity has one row for each combination of entity value and its validity period.

```yaml
semantic_models:
Expand Down Expand Up @@ -280,9 +281,11 @@ semantic_models:
- name: tier
type: categorical
primary_entity: sales_person
entities:
- name: sales_person
type: primary
type: natural
expr: sales_person_id
```

Expand Down

0 comments on commit 928fdbd

Please sign in to comment.