You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
9 Hrs
52 Min
38 Seg

Dimensión tipo 2

10/26
Resources

How does a slowly changing dimension type 2 work?

Within data analysis and database management, conceptualizing slowly changing dimensions (SCD) is fundamental. The SCD Type 2 dimension allows us to store the complete history of changes that occur in attributes over time in an efficient and structured manner. This is crucial when we need to keep an accurate historical record of changes in entities, such as students or customers. It allows us to clearly see the changes made to a record by adding new rows to the database each time an attribute is updated, rather than modifying existing rows.

What are the currency fields?

The "start date" and "end date" fields, which are key to this dimension model, identify the validity of a record within a given period. When an attribute changes for a specific individual, the system closes the validity of the old record by assigning it an "end date" and generates a new record with a "start date". This time segmentation technique ensures that past and present data can always be accessed without losing information.

  1. Start date: Marks the moment at which a new record becomes valid.
  2. End date: Indicates when the validity of the record ends, aligning the date of the new change.

How is the change implemented in an SCD Type 2?

Let's look at a concrete and practical example. Suppose that a student, named Pepito Perez, originally enrolled in the Faculty of Engineering, changes to the Faculty of Health. During this process, the slowly changing dimension type 2 executes the following actions:

  • Searching for the current record: The data extraction and transformation (ETL) process searches for the most recent record in the dimension, in this case, the last update on February 24, 2030.
  • Creating a new record: Identifying that the change to the College of Health is after February 24, ETL creates a new record ID but retains the same student code.
  • Adjustment of effective dates: The old record closes on March 24, 2030. The new record for the College of Health starts at a date that may include a small extra duration (such as one minute) to prevent overlaps when searching.

The dimension, then, ensures the integrity and full traceability of the student's historical status.

How to prevent data quality problems in ETL?

It is important to consider common events, such as fictitious dates or data errors, in the data extraction and transformation stages. For example, the date February 30 does not exist. It is vital to implement ETL checks to identify and correct these problems, ensuring quality and reliability in the Data Warehouse. This procedure prevents future errors and facilitates the correct application of SCD Type 2, enabling informed decisions to be made.

How to manage future end dates?

The right approach to setting end dates on current records is key:

  • Use of null values: Marking the "end date" as null indicates that the record is still current, i.e., active for the current day.
  • Assigning future dates: If it is desired to avoid null values, a conventional date, such as December 31, 9999, can be used to signify an indefinite future.

Each decision about how to handle these dates depends on the internal policies of the organization and how you wish to view historical data.

The ability to successfully manage these changes is vital to ensure that data operations are smooth and accurate, improving business decisions based on real historical data. This prompts continuous optimization of ETL processes to meet complex challenges with confidence.

Contributions 3

Questions 3

Sort by:

Want to see more contributions, questions and answers from the community?

La dimensión tipo 2 es aquella que trata los cambios en los atributos de las dimensiones lentamente cambiantes creando un nuevo registro con el valor nuevo y marcando el registro antiguo como no vigente. Se conserva el historial de cambios, pero se aumenta el tamaño de la tabla y se complican las consultas.

Un ejemplo práctico de dimensión tipo 2 podría ser el siguiente:

Supongamos que tenemos una dimensión de empleados con los atributos código, nombre, apellido, departamento y salario.

Si un empleado cambia de departamento o de salario, creamos un nuevo registro con el valor nuevo y ponemos una fecha de fin de vigencia al registro antiguo. De esta forma, podemos tener varios registros para el mismo empleado, cada uno con un período de vigencia diferente.

Esto nos permite analizar los datos históricos según el departamento o el salario que tenía el empleado en cada momento, pero también implica tener más registros y más complejidad para filtrar o agrupar los datos.

Una **dimensión tipo 2** es un tipo de dimensión en un Data Warehouse diseñada para **rastrear y preservar el historial de cambios en los datos**. A diferencia de una dimensión tipo 1, que sobrescribe los valores antiguos, la dimensión tipo 2 crea una nueva fila en la tabla para cada cambio, permitiendo conservar los datos históricos. ### **Características principales:** 1. **Registro del historial:** Cada cambio en un atributo de la dimensión se guarda como una nueva fila en la tabla. 2. **Identificadores únicos:** Cada versión de un registro tiene un identificador único o clave sustituida (**surrogate key**) para diferenciar las versiones del mismo objeto. 3. **Control de vigencia:** Se utilizan columnas para rastrear el período de tiempo en que cada versión estuvo activa, como fechas de inicio y fin o un indicador de "fila activa". ### **Casos de uso:** * Cuando es necesario analizar datos históricos o realizar un seguimiento de cómo han cambiado los valores a lo largo del tiempo. * Ideal para áreas donde los cambios en atributos impactan el análisis, como datos de clientes, ubicaciones o productos. ### **Ejemplo práctico:** Supongamos que tienes una tabla de dimensión para clientes: #### Estado inicial: SK\_ClienteID\_ClienteNombreCiudadFecha\_InicioFecha\_FinActivo11001JuanBogotá2024-01-019999-12-31Sí #### Cambio: Juan se muda de Bogotá a Medellín el 2024-06-01. #### Estado actualizado: SK\_ClienteID\_ClienteNombreCiudadFecha\_InicioFecha\_FinActivo11001JuanBogotá2024-01-012024-05-31No21001JuanMedellín2024-06-019999-12-31Sí ### **Ventajas:** * Permite análisis históricos al conservar el contexto de los datos en el tiempo. * Facilita el seguimiento de cambios relevantes para los negocios. ### **Desventajas:** * Aumenta la complejidad y el tamaño de la tabla debido a la creación de múltiples versiones. * Requiere procesos ETL más elaborados para manejar las fechas de vigencia y los indicadores de estado. La dimensión tipo 2 es una excelente opción cuando los cambios en los datos son críticos para el análisis de negocios y la toma de decisiones.

Excelente que se expliquen cosas “obvias” porque muchas veces esto no se hacen y despues no se entienden las cosas mas avanzadas.