SQL & Data Management

Chapter 10
Data Integration, Quality, and Metadata

Bachelors Program in Business Analytics
SQL & Data Management   •   Bachelor

Data Integration, Quality, and Metadata

Introduction

Business analytics depends on more than having large quantities of data. Analysts need data that can be combined correctly, interpreted consistently, traced to its sources, and trusted for decision-making. In practice, data is distributed across operational databases, cloud applications, spreadsheets, APIs, files, sensors, and external providers. These sources differ in structure, naming conventions, update frequency, granularity, and quality. Data integration brings them together; data-quality management evaluates and improves their fitness for use; metadata explains what the data means and how it has changed.

This chapter examines the design of ETL and ELT pipelines, data profiling, cleansing, validation, entity matching, lineage, and master data management. It also introduces measurable data-quality dimensions and connects technical design with governance, ethics, security, and business value.

Learning Objectives

By the end of this chapter, you should be able to:

  1. Distinguish ETL, ELT, batch, streaming, and incremental integration patterns.
  2. Design a reliable pipeline from source extraction to curated analytical data.
  3. Profile data and measure completeness, validity, uniqueness, consistency, timeliness, and accuracy.
  4. Apply cleansing, validation, standardization, deduplication, and entity-matching techniques.
  5. Explain technical, business, operational, and lineage metadata.
  6. Use master data management to establish trusted shared entities.
  7. Evaluate data-integration risks, including privacy, bias, security, and uncontrolled change.

1. Data Integration as an Analytical Capability

Data integration is the controlled combination of data from multiple sources so that it can be used consistently. A simple SQL join is one form of integration, but enterprise integration is broader. It includes discovering sources, mapping fields, transporting records, transforming formats, reconciling conflicts, monitoring execution, and documenting lineage.

Integration is difficult because systems represent the same business concept differently. A customer may be identified by customer_id in a CRM system, an email address in a marketing platform, and an account number in an invoicing system. One source may store dates as 2025-03-08, another as 08/03/2025, and a third as a timestamp in UTC. A product category may be “Mobile Phones,” “Phones,” or “MOB.” Unless these differences are managed explicitly, combined reports can double-count customers, misstate revenue, or compare incompatible measures.

A useful principle is that integration should preserve meaning, not merely move records. Every transformation should have a stated purpose, a defined owner, and a way to verify its result.

Common integration architectures

A traditional data warehouse often follows a staged architecture:

  1. Source systems: operational databases, files, SaaS applications, and external feeds.
  2. Landing or raw zone: an immutable copy of extracted data.
  3. Staging layer: temporary structures used for parsing and technical transformation.
  4. Conformed or integrated layer: common keys, units, names, and business definitions.
  5. Presentation layer: dimensional models, analytical tables, dashboards, or data marts.

A data lake or lakehouse may retain raw files and support transformation using SQL, distributed processing, or notebooks. The architectural labels differ, but the requirements remain similar: preserve source evidence, apply controlled transformations, test outputs, and document provenance.

2. ETL and ELT Pipelines

ETL

ETL means extract, transform, load. Data is extracted from sources, transformed in an intermediate processing environment, and then loaded into the target warehouse. ETL can be appropriate when the target has limited processing capacity, when sensitive data must be filtered before arrival, or when transformations are standardized in a separate integration tool.

ELT

ELT means extract, load, transform. Data is loaded into a scalable target platform in raw or lightly processed form and transformed there using SQL or platform-native tools. ELT is common in cloud warehouses because storage and compute can scale independently. It also preserves raw data for reprocessing when business rules change.

Neither pattern is universally superior. The choice depends on cost, latency, data sensitivity, target capabilities, skills, and the need to reproduce historical transformations.

ConsiderationETLELT
Transformation locationBefore target loadingInside target platform
Raw-data retentionMay be limited unless designed explicitlyUsually straightforward
Main strengthControlled preprocessing and source isolationScalable, flexible analytical transformation
Main riskRigid pipelines and duplicated logicUncontrolled transformations and warehouse cost
Suitable contextRestricted targets or heavy source-side cleansingCloud warehouses and lakehouses

Batch and streaming integration

Batch processing collects records and processes them at scheduled intervals. It is suitable for payroll, daily sales summaries, and many finance processes. Streaming processing handles events continuously or in small time windows. It is useful for fraud detection, equipment monitoring, and real-time personalization.

Streaming does not eliminate the need for quality controls. It introduces additional concerns: late-arriving events, duplicate messages, out-of-order timestamps, replay, and exactly-once or at-least-once delivery semantics. A robust design uses event identifiers, ingestion timestamps, watermarks, and idempotent processing. An idempotent operation produces the same final state when the same event is processed more than once.

Full and incremental loads

A full load copies all available records. It is simple but may be expensive and can place stress on source systems. An incremental load copies only new or changed records. Common methods include:

  • Timestamp extraction: select rows changed after the last successful extraction.
  • Change data capture (CDC): capture inserts, updates, and deletes from database logs or source mechanisms.
  • High-water mark: record the greatest processed sequence number or event time.
  • Snapshot comparison: compare successive snapshots when source change information is unavailable.

Incremental logic must account for updates that arrive late, clock differences, deleted records, and failed or partially completed runs. A pipeline should record its extraction boundary only after successful processing, not before.

Pipeline control and observability

A production pipeline is more than a sequence of SQL statements. It requires:

  • dependency management and scheduling;
  • parameterized environments and credentials;
  • schema-change detection;
  • row-count and control-total checks;
  • error quarantine and retry policy;
  • logging of start time, end time, status, and affected rows;
  • alerts with actionable information;
  • rerun and recovery procedures.

A useful control total is the sum of a trusted measure, such as invoice value, before and after transformation. If the total changes, the difference must be explained by filtering, currency conversion, reversals, or another documented rule.

3. Data Profiling and Quality Dimensions

Data profiling is the systematic examination of data content, structure, and relationships. Profiling should occur before designing transformations and should continue after deployment. It combines database metadata, descriptive statistics, pattern analysis, and relationship checks.

Typical profiling questions include:

  • What percentage of values are null or blank?
  • Which values occur most frequently?
  • Are dates within an expected range?
  • Are identifiers unique?
  • Do foreign keys match parent keys?
  • Are numeric distributions changing unexpectedly?
  • Which fields contain personal or confidential information?

Measurable quality dimensions

Quality is not a single property. It is fitness for a specified business use. The following dimensions are widely used.

DimensionMeaningExample measure
CompletenessRequired information is presentNon-null required values ÷ required values
ValidityValues conform to allowed formats or rulesValid records ÷ inspected records
AccuracyValues represent the real-world object correctlyVerified correct values ÷ verified values
ConsistencyRelated representations do not conflictRecords passing consistency rules ÷ tested records
UniquenessNo unintended duplicate representations existUnique entities ÷ identified entities
TimelinessData is available and current when neededRecords within freshness threshold ÷ records
IntegrityRelationships and constraints are preservedValid referential relationships ÷ tested relationships

For a dataset with N records, if nnull records lack a required value, completeness is:

Completeness = (N − nnull) ÷ N × 100%

Here, N and nnull must refer to the same population and field requirement. The measure is meaningful only when the required-field rule is explicit.

If 9,500 of 10,000 customer records contain a valid phone number, phone completeness is 95%. This does not establish accuracy: a syntactically valid phone number may still belong to another person.

A rule-conformance rate can be calculated as:

Validity rate = nvalid ÷ N × 100%

If 980 of 1,000 transactions have an allowed currency code, validity is 98%. Rates should be reported with the population, time period, rule version, and exclusion criteria.

Quality measures can be combined into a score, but a weighted score should not hide serious failures. For example, an average of high completeness and low accuracy may look acceptable while customer decisions remain unsafe. Thresholds and critical rules are often more useful than a single overall score.

4. Cleansing, Standardization, and Validation

Cleansing and standardization

Cleansing modifies data to correct, remove, or isolate defects. Common actions include trimming whitespace, converting character case, normalizing dates, standardizing units, correcting known codes, and separating invalid records for review.

Standardization must be governed by a semantic rule. Converting “kg” to “kilograms” is harmless if the unit is known; converting “12” without knowing whether it means kilograms, pounds, or units is not. Similarly, converting all names to uppercase may improve matching but can damage legitimate capitalization used in display systems.

A practical cleansing sequence is:

  1. Preserve the original value.
  2. Create a standardized working value.
  3. Apply deterministic validation rules.
  4. Record the rule, result, and timestamp.
  5. Send unresolved exceptions to a review queue.
  6. Publish only approved or explicitly classified records.

Validation types

Domain validation checks permitted values, such as status being one of Open, Closed, or Pending.

Range validation checks numerical or temporal limits, such as quantity being greater than or equal to zero.

Format validation checks patterns, such as an identifier matching a defined structure. A pattern check does not prove that the identifier exists.

Cross-field validation checks relationships within a record. For example, a shipment date should not precede an order date when both use the same time convention.

Referential validation checks relationships between tables. Every non-null product_id in a sales fact table should refer to an approved product record, unless the business explicitly allows an “unknown product” member.

SQL constraints provide an important first line of defense:

CREATE TABLE order_line (
    order_id       BIGINT NOT NULL,
    product_id     BIGINT NOT NULL,
    quantity       INTEGER NOT NULL CHECK (quantity > 0),
    unit_price     DECIMAL(12,2) NOT NULL CHECK (unit_price >= 0),
    PRIMARY KEY (order_id, product_id)
);

Constraints should be complemented by pipeline tests because many analytical platforms permit flexible ingestion and because business rules may span multiple tables.

5. Matching, Deduplication, and Entity Resolution

Matching determines whether records refer to the same real-world entity. Deduplication removes or consolidates unintended repeated representations. These processes are central to customer analytics, supplier management, and regulatory reporting.

Deterministic matching

Deterministic matching uses exact or rule-based comparisons, such as a verified national identifier, account number, or normalized email address. It is transparent and easy to audit but fails when values are missing, mistyped, or changed.

Probabilistic or similarity matching

Similarity matching compares several attributes, such as name, address, telephone number, and date of birth. It may use edit distance, token similarity, phonetic encoding, or a trained classification model. Similarity is not identity. Thresholds should be calibrated using labeled examples, and uncertain matches should be reviewed rather than automatically merged.

A simple weighted comparison can be represented as:

S = w₁s₁ + w₂s₂ + … + wₖsₖ

Here, si is the similarity score for attribute i, wi is its weight, and the weights should be non-negative and sum to 1. This expression is a decision aid, not a universal law. Its validity depends on appropriate similarity functions, representative training or calibration data, and a documented decision threshold.

For example, an organization may give greater weight to a verified government identifier than to a surname. It should avoid treating protected or sensitive attributes as convenient matching keys without a lawful and ethical basis.

Survivorship and merge policy

When duplicates are confirmed, a master record must be selected or constructed. A survivorship rule may choose the most recently verified address, the value from a trusted system, or a non-null value with the strongest evidence. The system should retain source values and a cross-reference table so that the merge can be reversed or explained.

Over-aggressive matching creates false positives: two different people become one. Conservative matching creates false negatives: one person remains fragmented across records. The appropriate balance depends on the cost of each error and the decision context.

6. Metadata and Data Lineage

Metadata is data about data. It makes datasets discoverable, understandable, usable, and governable.

Types of metadata

  • Technical metadata: table names, column types, indexes, partitions, formats, and schema versions.
  • Business metadata: definitions, owners, classifications, approved terminology, and calculation rules.
  • Operational metadata: load times, job status, row counts, failures, and processing duration.
  • Process metadata: transformation logic, dependencies, and workflow relationships.
  • Security metadata: sensitivity labels, access classifications, retention requirements, and masking rules.

A business glossary might define “active customer” as a customer with at least one completed purchase during the previous 12 months. Without the definition, two departments may produce different but apparently reasonable counts.

Lineage

Data lineage records where data came from, what happened to it, and where it is used. Upstream lineage traces a dashboard measure back to source fields. Downstream lineage identifies reports, models, or processes affected by a source change.

Lineage can be captured at several levels:

  • table-to-table lineage;
  • column-to-column lineage;
  • record-level lineage for high-risk processes.

Lineage supports impact analysis, audit, troubleshooting, regulatory explanation, and trust. It should identify transformation versions and business-rule owners, not merely draw arrows between systems.

7. Master Data Management

Master data consists of relatively stable shared entities used across processes, such as customers, products, suppliers, employees, locations, and chart-of-account elements. Master Data Management (MDM) establishes authoritative definitions, identifiers, stewardship responsibilities, and synchronization rules.

An MDM program commonly includes:

  1. Identification: determine which entities require shared management.
  2. Modeling: define attributes, relationships, and valid states.
  3. Matching: connect source records to master entities.
  4. Survivorship: determine trusted values.
  5. Governance: assign owners, stewards, approval rules, and escalation paths.
  6. Distribution: publish mastered data to consuming systems.
  7. Monitoring: measure quality, synchronization, and unresolved exceptions.

MDM can be centralized, registry-based, or coexistence-based. A centralized model stores the authoritative master in one hub. A registry links records across systems while leaving source values in place. A coexistence model allows multiple systems to maintain data while synchronization rules coordinate changes.

MDM is not simply a software purchase. It is an organizational agreement about definitions, authority, accountability, and acceptable change. If departments disagree about what a customer or product means, technology alone cannot resolve the disagreement.

8. Applied Case: Retail Customer Integration

The following is an illustrative case.

Background

Northstar Retail operates physical stores, an e-commerce site, and a loyalty application. Management wants a unified customer view to measure customer lifetime value and personalize promotions. The store system uses a loyalty number, the website uses an email address, and the application uses a device-linked account identifier.

Problem

A preliminary analysis reports 2.4 million customers, but finance records only 1.6 million paying accounts. Profiling shows missing emails, inconsistent phone formats, repeated household addresses, and different treatment of canceled accounts. Marketing campaigns are sent multiple times to some people and not at all to others.

Analysis

The team establishes a data-quality baseline. Of 1,000,000 web profiles, 84% have a non-null email, but only 76% pass the organization’s email validation rule. Of 600,000 store-linked records, 91% have a loyalty number. Exact matching identifies 1.1 million relationships; similarity matching produces another 180,000 candidate relationships. A sample review estimates that 92% of accepted similarity matches are correct, while 18% of borderline candidates are incorrect.

The team therefore separates automatic matches from manual review. It also discovers that “customer” is inconsistently defined: the website counts registered visitors, while finance counts customers with a completed transaction.

Approach and solution

The organization designs an ELT pipeline with a raw zone that preserves source records and ingestion timestamps. Standardization rules normalize email case, telephone representation, address abbreviations, and country codes. Each source record receives a durable source key and is linked to a master customer identifier.

A deterministic match is accepted for verified loyalty numbers and approved account identifiers. Similarity matching is used only when multiple attributes agree. Candidate pairs below the review threshold are quarantined. A survivorship policy prefers verified contact information, records the source and verification date, and retains prior values for audit.

The business glossary defines “active customer” as a person or organization with at least one completed purchase in the preceding 12 months. A dashboard lineage record connects the active-customer measure to the transaction status, transaction date, master-customer link, and definition version.

Outcome

Duplicate campaign recipients fall substantially, and analysts can reconcile customer counts to finance under the shared definition. The organization does not claim perfect accuracy; instead, it reports match confidence, unresolved candidates, and quality trends. The pipeline also detects a later upstream change in telephone formatting before it affects the marketing dashboard.

Learning points

The case demonstrates that integration, quality, metadata, and MDM are interdependent. Matching without definitions creates confusion; cleansing without lineage removes evidence; and a dashboard without measurable quality cannot communicate decision risk.

9. Governance, Ethics, Security, and Contemporary Practice

Data integration can amplify harm when inaccurate or biased data is combined at scale. A mistaken identity match may expose private information or cause an unfair eligibility decision. Sensitive attributes should be collected and used only for legitimate, documented purposes. Access should follow least privilege, and personal data should be encrypted in transit and at rest where appropriate.

Governance practices include data ownership, stewardship, retention schedules, access reviews, change approval, incident response, and documented lawful bases for processing. Organizations should distinguish data quality from data completeness: collecting more personal data is not automatically better.

AI-assisted profiling and matching can accelerate pattern discovery, but models may reproduce historical bias, conceal reasoning, or make irreversible merges. Human review is appropriate for high-impact decisions and ambiguous matches. AI-generated transformations should be tested, version-controlled, and reviewed by accountable professionals.

Contemporary platforms increasingly support data contracts, automated quality tests, observability, schema registries, catalog search, and policy-as-code. A data contract specifies expectations between producers and consumers, including schema, semantics, freshness, and allowable changes. These tools improve reliability but do not replace business ownership or clear definitions.

10. Best Practices and Limitations

Effective data-integration programs generally follow these practices:

  • begin with business-critical data products and measurable use cases;
  • preserve raw evidence and never overwrite source values without traceability;
  • define keys, grain, units, time zones, and null semantics explicitly;
  • use incremental processing carefully and make reruns safe;
  • test both technical conditions and business rules;
  • publish quality metrics with denominators, thresholds, and time periods;
  • separate automatic decisions from exceptions requiring review;
  • maintain a glossary, catalog, lineage, and ownership model;
  • monitor schema changes and data drift;
  • secure personal and confidential data throughout the pipeline.

There are also limitations. Accuracy is often difficult to measure because the true value may require external verification. Similarity matching can be culturally and linguistically uneven. Quality scores may reward easy-to-measure fields while ignoring important but unmeasured problems. Lineage tools may fail to capture logic hidden in notebooks or manually edited spreadsheets. Finally, centralized governance can become slow if approval processes are excessive. Good design balances control with operational usefulness.

Chapter Summary

Data integration combines heterogeneous sources while preserving business meaning and operational evidence. ETL transforms before loading, whereas ELT loads data before transformation; batch and streaming designs address different latency requirements. Reliable pipelines require incremental-load controls, idempotence, monitoring, error handling, and recovery procedures.

Data profiling reveals nulls, invalid values, duplicates, distribution changes, and broken relationships. Completeness, validity, accuracy, consistency, uniqueness, timeliness, and integrity should be measured against explicit populations and rules. Cleansing should preserve original values and document each transformation. Entity resolution uses deterministic or similarity-based matching, with thresholds and human review for uncertain cases.

Metadata explains technical structure, business meaning, operations, security, and transformation processes. Lineage supports impact analysis and audit. Master Data Management creates shared identifiers, trusted attributes, stewardship, and synchronization across systems. Governance, privacy, security, and fairness are essential because integrated data can magnify both value and harm.

Key Terms

Data integration: Controlled combination of data from multiple sources for consistent use.

ETL: Extract, transform, and load processing pattern.

ELT: Extract, load, and transform processing pattern.

Batch processing: Processing data in scheduled groups.

Streaming: Continuous or near-continuous processing of events.

Change data capture: Technique for identifying source inserts, updates, and deletes.

Idempotence: Property whereby repeated processing produces the same final state.

Data profiling: Systematic examination of data structure, content, and relationships.

Completeness: Degree to which required data is present.

Validity: Conformance to defined formats, domains, or rules.

Accuracy: Degree to which data represents the real-world object correctly.

Data cleansing: Correction, standardization, or isolation of defective data.

Entity resolution: Determining whether records represent the same entity.

Survivorship: Rule for selecting trusted values when records are merged.

Metadata: Information that describes data and its context.

Data lineage: Trace of data origins, transformations, and destinations.

Master Data Management: Governance and technology for shared core entities.

Data steward: Person accountable for the definition, quality, and proper use of a data domain.

Data contract: Explicit agreement about a dataset’s schema, semantics, quality, and change expectations.

Review Questions

Short Answer Questions

  1. What is the primary difference between ETL and ELT?
  2. Why should raw source values usually be preserved during cleansing?
  3. Define data lineage and state one practical benefit.
  4. What is the difference between completeness and accuracy?
  5. Why are uncertain entity matches often sent for human review?

Long Answer Questions

  1. Explain how a production-grade incremental pipeline should handle late-arriving records, failures, duplicates, and deletes.
  2. Compare deterministic and similarity-based entity matching, including their strengths, risks, and appropriate controls.
  3. Discuss the role of technical, business, operational, and security metadata in an analytical organization.
  4. Explain how Master Data Management combines technology, governance, stewardship, and business definitions.
  5. Design a data-quality framework for a sales warehouse using at least five measurable quality dimensions.

Analytical / Application Questions

  1. A customer table contains 50,000 records, of which 2,750 lack a required country code. Calculate completeness and explain what additional evidence would be needed to assess accuracy.
  2. A source system changes a product-code format without notice. Propose pipeline controls that would detect, contain, diagnose, and safely recover from the change.
  3. Two systems report different numbers of “active customers.” Develop a reconciliation approach using definitions, profiling, lineage, matching, and governance.

Multiple Choice Questions with Answers

Question 1

Which statement best describes ELT?

A. Data is transformed before it leaves the source system

B. Data is extracted, loaded into the target platform, and transformed there

C. Data is loaded only after manual cleansing by business users

D. Data is integrated exclusively through real-time events

Correct Answer: B. Data is extracted, loaded into the target platform, and transformed there

Question 2

Which control is most useful for making repeated processing of the same event safe?

A. Idempotent processing

B. Increasing dashboard refresh frequency

C. Removing ingestion timestamps

D. Disabling retries

Correct Answer: A. Idempotent processing

Question 3

A field has 9,500 non-null values among 10,000 required records. What is its completeness?

A. 5%

B. 90%

C. 95%

D. 99.5%

Correct Answer: C. 95%

Question 4

Which quality dimension asks whether a value conforms to an allowed format or rule?

A. Accuracy

B. Validity

C. Timeliness

D. Uniqueness

Correct Answer: B. Validity

Question 5

What is the main purpose of preserving original values during cleansing?

A. To increase storage costs deliberately

B. To prevent all transformations from occurring

C. To support auditability and recovery

D. To guarantee that values are accurate

Correct Answer: C. To support auditability and recovery

Question 6

Which matching approach is generally most transparent when a verified account identifier is available?

A. Deterministic matching

B. Unsupervised clustering only

C. Random sampling

D. Unrestricted fuzzy matching

Correct Answer: A. Deterministic matching

Question 7

What does upstream lineage show?

A. Which users viewed a dashboard

B. How a report field traces back to source data

C. The physical location of a server only

D. The number of records rejected by a constraint only

Correct Answer: B. How a report field traces back to source data

Question 8

Which item is business metadata?

A. Column data type

B. Job execution duration

C. Definition of an active customer

D. Network bandwidth

Correct Answer: C. Definition of an active customer

Question 9

What is a central purpose of Master Data Management?

A. To eliminate every operational database

B. To establish shared entities, identifiers, and trusted values

C. To store only unstructured documents

D. To replace all data-quality measurements with a single score

Correct Answer: B. To establish shared entities, identifiers, and trusted values

Question 10

Why should borderline similarity matches often be reviewed?

A. Similarity scores prove identity automatically

B. They may create false-positive merges

C. Review makes lineage unnecessary

D. They cannot contain personal information

Correct Answer: B. They may create false-positive merges

SQL & Data Management
Chapter 10 of 15