Data Integration and Transformation - ETL Overview
ETL OVERVIEW
ETL stands for Extract, Transform and Load.
Purpose: collect data from various sources, transform the data according to business rules/needs, and load the data into a destination database (data warehouse).
ETL is often a complex mix of processes and technology.
It consumes a significant portion of data warehouse development efforts and requires skills from business analysts, database designers, and application developers.
Because ETL is an integral, ongoing, and recurring part of a data warehouse, it should be:
Automated
Well documented
Easily changeable
MAIN STEPS IN THE ETL PROCESS
ETL PROCESS INVOLVES THREE CORE STEPS: EXTRACT, TRANSFORM, LOAD.
ETL is typically implemented as an automated, well-documented, and configurable lifecycle between sources and the warehouse.
ETL STAGING AREA
ETL operations should be performed in a separate intermediate storage area called the staging area.
The staging area sits between the data sources and the target data warehouse.
Staging can be implemented as:
Tables in relational databases
Text-based flat files (or XML files) in file systems
Proprietary formatted binary files in file systems
Benefits:
Creates logical and physical separation between sources and the data warehouse.
Minimizes the impact of intensive ETL activity on source and warehouse databases.
OVERVIEW OF DATA EXTRACTION
Extraction: reading data from different sources to load into the data warehouse.
It is the first step of ETL, followed by many other steps.
Why it is complex:
Data come from heterogeneous and inconsistent sources.
Many source systems are poorly documented.
Each data source has its own characteristics to manage and integrate.
Often, source systems cannot easily add logic to support incremental extraction due to performance/workload concerns.
DATA EXTRACTION ISSUES
Key concerns when extracting data:
1) Source identification: identify source applications and structures.
2) Method of extraction: manual vs. tool-based.
3) Extraction frequency: daily, weekly, quarterly, etc.
4) Time window: define the time window for extraction.
5) Job sequencing: determine if one job must wait for the previous job to finish.
6) Exception handling: define how to handle input records that cannot be extracted.
SOURCE IDENTIFICATION
Identify all proper data sources and verify they provide the necessary value to the data warehouse.
Accuracy and comprehensive analysis are essential in source identification.
DATA IN OPERATIONAL SYSTEMS
Data in source systems are time-dependent (temporal) and change over time.
History is critical in the data warehouse (e.g., address changes affecting historical analyses).
Two broad categories of operational data:
Current Value: the value at the present moment (transient).
Periodic Status: status value preserved at change events; history is kept in the source.
DATA IN OPERATIONAL SYSTEMS – CURRENT VALUE
Examples: customer name/address, bank account balances, outstanding order amounts.
Challenge: preserving history for the data warehouse is more involved for this category.
DATA IN OPERATIONAL SYSTEMS – PERIODIC STATUS
Value is preserved as status each time a change occurs.
History is preserved in the source systems themselves, making extraction for history easier.
DATA EXTRACTION TECHNIQUES
Two major types of extractions:
1) As Is (static data): capture data at a given point in time (snapshots).
2) Incremental data capture: capture revisions since the last extraction (immediate or deferred).
IMMEDIATE DATA EXTRACTION
Real-time data extraction: occurs as transactions happen in source databases/files.
Three options:
1) Capture through Transaction Logs
2) Capture through Database Triggers
3) Capture in Source Applications
CAPTURE THROUGH TRANSACTION LOGS
Uses DBMS transaction logs that record every insert/update/delete for recovery purposes.
Reads the log to select committed transactions.
Advantages: minimal overhead since logging is already part of processing.
Broad steps for replication-based capture:
Identify source system table
Define target files in staging area
Create mapping between source table and target files
Define replication mode
Schedule replication
Capture changes from logs
Move changes from logs to target files
Verify transfer
Confirm success/failure and document outcome in metadata (sources, targets, mappings)
CAPTURE THROUGH DATABASE TRIGGERS
Applies to database applications as source systems.
Triggers are stored procedures activated by predefined events.
Output goes to a separate file to be used for DW extraction.
Pros: reliable data capture at the source.
Cons: adds overhead during transaction processing on the source system.
CAPTURE IN SOURCE APPLICATIONS
Requires revising application programs to write changes (adds/updates/deletes) to source files/tables.
Applicable to all types of source data (databases, indexed files, flat files).
Cons: large scope if many source programs; may degrade source system performance due to extra processing.
DEFERRED DATA EXTRACTION
Deferred techniques do not capture changes in real time.
Two options:
1) Capture Based on Date and Time Stamp
2) Capture by Comparing Files
CAPTURE BASED ON DATE AND TIME STAMP
Source records get date/time stamps on create/update.
Extraction later uses stamps to select relevant records.
Best when the number of revised records is small and all relevant records contain timestamps.
Captures the latest state of the source data.
CAPTURE BY COMPARING FILES
Last-resort technique when other methods are not feasible.
Also called the snapshot differential technique because it compares two snapshots of source data.
Requires keeping prior copies of all relevant source data.
Simple but potentially inefficient for large files.
EVALUATION OF THE TECHNIQUES
Summary of options for data extraction:
1) Capture of Static Data
2) Incremental Data Capture
A. Immediate Data Extraction
- Capture through transaction logs
- Capture through database triggers
- Capture in source applications
B. Deferred Data Extraction
- Capture based on date and time stamp
- Capture by comparing files
DATA TRANSFORMATION
Transformation is the process of converting extracted data from its original state into a consistent state suitable for loading into another database.
Extracted data is raw and not immediately usable in the data warehouse.
Data from old/legacy systems is often of insufficient quality and needs enrichment and quality improvement before use.
Transformation must align data to standards across diverse source systems and ensure business rules are not violated.
A major focus of transformation is improving data quality.
DATA TRANSFORMATION (CONT.)
Data Quality paradigm:
Correct (Unambiguous)
Consistent
Complete
Data quality checks are performed at two stages:
After extraction
After cleaning (and possibly further checks)
EXAMPLES OF INCONSISTENT DATA REPRESENTATIONS
Date value representations can vary widely (e.g., 970314, 1997-03-14, 03/14/1997, 14-MAR-1997, March 14 1997, 2450521.5 Julian date).
Gender representations can vary (Male/Female, M/F, 0/1, PM/AM).
MAJOR TRANSFORMATION TYPES
Format Revisions: standardize data types/lengths; e.g., codes vs text for product package types.
Decoding of Fields: map cryptic codes to meaningful values (e.g., 1/2 vs M/F; AC, IN, RE, SU to Active, Inactive, Regular, Suspended).
Calculated and Derived Values: compute totals, margins, etc. (e.g., profit margin, average daily balances, operating ratios).
Splitting of Single Fields: break out first/middle/last name; city/state/zip; improves indexing and analysis.
Merging of Information: combine data from multiple sources into a single entity (e.g., product code from one source, description from another, costs from a third).
Character Set Conversion: convert between EBCDIC and ASCII as needed; address cross-platform text representations.
Conversion of Units of Measurements: unify metric vs other units across global operations.
Date/Time Conversion: standardize date/time formats (e.g., 10/11/2008 vs 11 OCT 2008).
Summarization: create summaries rather than storing every granular transaction (e.g., daily summaries for credit card transactions).
Key Restructuring: avoid meaningful keys; use system-generated surrogate keys for dimension/fact table keys.
Enrichment: rearrange/simplify fields to be more useful; create new fields from existing ones and from multiple records.
Deduplication: remove duplicate customer records to prevent errors and double counting.
Problems due to Data Duplication: false frequencies, incorrect aggregates, difficulty catching duplicate identities.
SLOWLY CHANGING DIMENSIONS (SCD)
Dimensional tables are generally more stable; changes occur slowly.
In OLTP, new values overwrite old ones; in DW, overwriting is not always appropriate.
Three types of dimension changes:
Type 1: Overwrite with new value; history not preserved.
Type 2: Add a new row with the new value and a surrogate key; preserves history.
Type 3: Add an old field; track the old value in a current row; no new row needed.
TYPE 1: Example — Susan's Tax Bracket from Medium to High (overwrite).
TYPE 2: Example — Add new row with new value and surrogate key; include effective date.
TYPE 3: Example — Keep old value in an old field, keep current value in a new field; no new row.
Pros/Cons:
Type 1: simple, but no history.
Type 2: accurate history, but dimension grows.
Type 3: tracks up to two changes; more compact but limited history.
TRANSFORMATION FOR DIMENSION ATTRIBUTES
Automatic data cleansing can be employed to improve data quality before loading.
AUTOMATIC DATA CLEANSING
1) Statistical Methods: identify outliers using mean, standard deviation, range, etc.
2) Pattern-based: detect non-conforming patterns; define a pattern as similar behavior for p% of fields (p often > 90%). Techniques include partitioning, classification, clustering.
3) Clustering: identify outliers by distance measures (e.g., Euclidean); computationally intensive.
4) Association rules: use rules with high confidence and support to define normal patterns; records not following rules are outliers.
DATA LOADING
Data Loading writes data to the target source and includes loading both dimension and fact tables.
Loads can be time-consuming; typically the warehouse is offline during loading.
Strategy: divide the load into smaller chunks (batching) and populate a subset at a time.
Also called loading the data or refreshing the data.
TYPES OF DATA LOADING
Initial load: populate all data warehouse tables for the first time.
Incremental load: apply ongoing changes periodically.
Full refresh: erase contents of one or more tables and reload with fresh data (initial load is a refresh of all tables).
APPLYING DATA: TECHNIQUES AND PROCESSES
Four modes to apply data to the warehouse:
Load: replace or populate target table contents.
Append: add new data, preserving existing data; handle duplicates as needed.
Destructive Merge: if incoming key matches, update; if new, insert.
Constructive Merge: if incoming key matches, keep existing, add incoming as a superseding record.
LOADING CHANGES TO DIMENSION TABLES
LOADING DIMENSIONS
Dimensions are built to minimize components; typically use Surrogate Keys as the primary key (meaningless unique integers).
The data warehouse owns surrogate keys and no external entity should assign them.
LOADING FACTS
When building a fact table, convert natural keys to surrogate keys.
ETL maintains a surrogate key lookup table for each dimension; updated when a new dimension entity is created or a change occurs.
All required lookup tables should be kept in memory for fast access during fact loading.
Lookup tables are often kept separate from the dimension tables for performance.
LOADING FACT TABLES (CONT.)
Managing Indexes during load:
Loading can be a performance killer; drop all indexes before pre-load, then recreate after.
Separate updates from inserts; load updates where appropriate; rebuild indexes after load.
ROLLBACK LOG
Rollback log (redo log) is valuable in OLTP but not necessary in a data warehouse ETL run.
Reasons to avoid rollback logging during ETL:
ETL processes are managed and bulk-loaded.
Data can be reloaded if a load fails.
Different DBMS have different logging features.
DATA REFRESH
Propagate updates on source data to the warehouse.
When to refresh:
Periodically (nightly, weekly) or after significant events.
On every update is usually not warranted unless current data is required (e.g., real-time stock quotes).
Refresh policy is set by the administrator and may differ by source.
ETL TOOL OPTIONS
Vendors address ETL challenges via tools in three broad categories:
Data transformation engines
Data capture through replication
Code generators
ETL TOOL OPTIONS (CONT.)
Data transformation engines:
Capture data from designated sources at user-defined intervals.
Perform elaborate data transformations.
Apply data to target files and support full and incremental loads.
Offer flexibility to point to various sources and transformation methods.
Data capture through replication:
Use transaction recovery logs to replicate changes in near real time to the staging area.
Some tools use database triggers for replication.
Code generators:
Generate 3GL/4GL data extraction and transformation programs from parameters, rules, and target layouts.
Tools generate code in common programming languages.
MAJOR CAPABILITIES OF ETL TOOLS
Extract data from relational databases and legacy systems.
Transform data between formats with different source/target schemas.
Apply standard conversions, key reformatting, and structural changes.
Provide audit trails from source to target.
Enforce business rules during extraction and transformation.
Combine multiple source records into a single integrated target record.
Manage and store metadata about the ETL process.
ETL SUMMARY AND APPROACH
High-level summary of ETL steps: EXTRACT, TRANSFORM, LOAD (diagrammatic representation shows the flow from Legacy Systems and Archived data through EXTRACT, TRANSFORM, and LOAD into Data Warehouse/OLAP environments).
Emphasizes the continuous nature of ETL in data warehousing and its role in enabling analytics and reporting.
ADDITIONAL NOTES
The material includes references to: data integration components, staging areas, and various extraction/transformation/loading strategies.
Wherever appropriate, the content uses examples to illustrate concepts (e.g., currency/date formats, gender coding, tax bracket history, surrogate keys).
KEY TAKEAWAYS
ETL is the backbone of data warehousing, combining data from diverse sources into a clean, usable form.
A well-designed ETL process uses a staging area to protect sources and the warehouse.
Extraction, transformation, and loading each have multiple methods and tradeoffs, especially regarding real-time vs deferred extraction and how to preserve history.
Data quality and consistency are central to transformation, with multiple techniques to cleanse and standardize data.
Slowly Changing Dimensions require careful handling (Type 1, Type 2, Type 3) to balance history retention and storage.
ETL tools offer a spectrum of capabilities from transformation engines to replication-based capture and code generation to support diverse environments.
Loading strategies and index management are critical for performance during large-scale data loads.