Saltar al contenido

Lección 8 · Data Architecture and Storage

Data Integration and Interoperability

Understand data integration patterns such as ETL, ELT, APIs, events and change data capture, and use mappings, data contracts and reconciliation checks.

Data integration moves and combines data from different systems. Interoperability is the ability of those systems to exchange data and understand it the same way. Moving bytes is the easy part. Agreeing that status = 2 means "shipped" is the hard part.

Common patterns

Pattern How it works Good for
Batch file or ETL Extract, transform, then load on a schedule Periodic reporting
ELT Load raw, then transform inside the target Cloud analytics
API calls One system asks another on demand Current, small requests
Events or messaging Systems publish changes for subscribers Loose coupling, near real time
Change data capture (CDC) Reads database changes and sends them on Keeping copies in step
Virtualization Query sources in place without copying Quick access, limited loads

There is no single best pattern. Consider freshness, volume, the load you place on sources, failure recovery and skills. For a deeper technical view, see ETL and ELT and incremental loading and CDC.

Source-to-target mapping

A mapping document says how each target field is produced. It is a small table that prevents large confusion:

Source field Rule Target field
crm.cust_no trim, keep as text customer_id
crm.ctry look up in country code table country_code
crm.created convert local time to UTC created_at_utc

State what happens to values that do not match: reject, default, or hold for review. Never invent a default that looks like real data, such as putting a real country code for "unknown".

Data contracts

A data contract is an agreement between a producer and consumers about a dataset: its fields, types, meaning, quality expectations, delivery schedule and how changes are announced. It turns hidden assumptions into something you can test. The next example checks incoming records against a small contract.

Python Validate records against a data contract

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

In practice, teams express contracts in a schema language or configuration file and run the checks in the pipeline. Decide in advance what happens on failure: block the load, quarantine the bad rows or warn.

Reconciliation

After moving data, prove that nothing was lost or changed by accident. Reconciliation compares counts and totals between source and target. Row counts alone can miss errors, so compare sums too, and check for missing keys.

SQL Reconcile source and target tables (SQL)

Press Run (or Ctrl + Enter) to see the result here.

Both tables have four rows, yet three problems exist. This is why count checks alone are not enough.

Design for failure

Networks fail and jobs run twice. Make loads idempotent: running them again gives the same result, for example by updating on a key instead of blindly appending. Keep logs of what was loaded and when. Set an expectation for how late data may arrive and alert when it is later.

Protect data in motion

Encrypt transfers, use dedicated service accounts with the least access needed and keep secrets such as API keys out of code and documents. When you share data with another organization, record the purpose, the legal basis where relevant, what is shared and when it must be deleted. Send only the fields the receiver needs.

Do not copy a whole table "just in case" when the consumer needs three columns. Every extra copied field is extra quality work and extra risk.

A worked example: designing one feed

A fictional events company needs ticket sales in its finance system. Before writing code, the team answers these questions:

Question Agreed answer
What is one record? One paid ticket
What identifies it? The ticket ID from the sales system
How fresh must it be? By the next morning
How are refunds shown? A separate refund record with the ticket ID
What if the feed fails? Retry, then alert the integration owner
How do we know it is complete? Daily count and amount totals match

The refund decision matters. Overwriting the original sale would hide history and make yesterday's totals change. A separate record keeps both facts.

Interoperability beyond formats

Two systems can both read the same file and still misunderstand it. Check four layers: transport (can the data arrive?), format (can it be parsed?), structure (are the fields where expected?) and meaning (do both sides mean the same thing?). Time zones, currencies, units, rounding rules and identifier schemes are frequent sources of meaning errors. Record them in the contract, and test with a few awkward cases: a refund, a late correction, a name with accents and a sale just before midnight.

Operating an integration

An integration needs care after launch. Give it an owner and a short run guide that explains the schedule, where logs are, what each alert means, how to rerun safely and whom to tell when data is late. Keep a list of consumers so you can warn them about outages and changes.

Watch for silent failures. A job can finish successfully while loading zero rows, because the source file was empty or a filter changed. Check that the result is plausible, not only that the job ended without an error. When you must correct data that was already sent, send an explicit correction and record why, so consumers can update their own copies.

Finally, retire feeds that nobody uses. Confirm with the listed consumers, stop the feed with notice, then remove its accounts, credentials and stored copies according to your retention rules.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. What does a data contract mainly do?

    A contract records fields, meaning, quality and change rules that both sides can check.
  2. 2. Source and target both have four rows. What can still be wrong?

    Counts can match even when rows differ. Compare keys and totals too.
  3. 3. What does it mean for a load to be idempotent?

    Idempotent loads are safe to retry after a failure.

Summary

  • Pick integration patterns by freshness, volume, load and recovery needs.
  • Document mappings, including how unknown values are handled.
  • Data contracts make expectations testable.
  • Reconcile keys and totals, not only row counts.
  • Make loads retry-safe and share only what is needed.

Next: Storage, Operations and Unstructured Content

Tu progreso se guarda en este navegador. No necesitas una cuenta.