Selecting Source Tables for Unification
Earn 25 points (50 with Pro) in two steps
- ① Read through the lesson — each section gets a ✓ as you scroll through it.
- ② When every section has a ✓, tap Complete lesson.
0 of 10 read · keep scrolling
✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro
Lesson: Selecting Source Tables for Unification
Introduction: The Foundation of Data Integration
In the world of data engineering and analytics, the process of bringing disparate data sources together into a single, unified view is known as data unification. Before you can clean, transform, or load data into a data warehouse or a data lake, you must first answer a fundamental question: "Which tables actually matter?" Selecting the correct source tables is the most critical decision in the data pipeline lifecycle. If you choose the wrong source or an incomplete set of tables, the downstream reports, machine learning models, and business decisions will be based on inaccurate or misleading information.
Data unification is not simply about moving rows from point A to point B. It is about understanding the semantic relationship between different datasets. When you are tasked with unifying data, you are essentially acting as a detective, tracing the lineage of business events back to their source of truth. Selecting source tables requires a deep understanding of the business domain, the technical architecture of the source systems, and the specific requirements of the end-users who will consume the unified data.
Why does this matter? Because data sprawl is a significant problem in modern organizations. Most companies collect data in dozens of siloed applications, ranging from customer relationship management (CRM) tools and enterprise resource planning (ERP) systems to custom web logs and third-party marketing APIs. If you attempt to unify everything without a strategy, you will end up with a "data swamp"—a massive collection of unorganized, redundant, and conflicting tables. Learning to select the right source tables allows you to build clean, performant, and reliable data products that provide genuine value to the organization.
Not read yet
Understanding the Landscape of Source Systems
Before you can select tables, you must categorize the systems you are dealing with. Data sources generally fall into a few primary categories, each with its own quirks and challenges. Recognizing these categories helps you anticipate potential issues during the mapping phase.
1. Transactional Systems (OLTP)
Transactional systems, such as a SQL database powering an e-commerce website, are designed for fast writes and high concurrency. These tables are often highly normalized, meaning a single "Order" might be split across Orders, Order_Items, Products, and Customers tables. When selecting tables from an OLTP system, you must be prepared to perform complex joins to reconstruct the business entity you actually care about.
2. Analytical Systems (OLAP)
These are existing data warehouses or data marts. While they might seem like "easy" sources because the data is already somewhat organized, they often contain pre-aggregated metrics that may not align with your new unification goals. You must be careful not to introduce "double counting" by pulling data that has already been transformed by a previous process.
3. SaaS Applications and APIs
Modern data pipelines often pull from tools like Salesforce, HubSpot, or Zendesk via APIs. These sources provide data in semi-structured formats, typically JSON. When mapping these, you are often selecting "endpoints" rather than traditional database tables. The challenge here is handling nested data structures and rate limits.
4. Raw Log Files and Event Streams
These are often the most granular sources of data. They capture every click, page view, or error message in a system. While they are the most "truthful" sources, they are also the most voluminous. Selecting these sources requires a clear strategy for filtering and aggregation, as you rarely need every single event for a general-purpose unified dataset.
Callout: The Source of Truth vs. The Source of Record It is important to distinguish between the 'Source of Record' and the 'Source of Truth'. The Source of Record is the system where the data is physically entered (e.g., the CRM). The Source of Truth is the system where the data is considered authoritative and consistent. Often, these are the same, but in complex organizations, you might have multiple systems claiming to be the truth. Your job is to identify the authoritative source for each attribute before you begin selecting tables.
Not read yet
Criteria for Evaluating Source Tables
Once you have identified the systems, how do you decide which tables to pull? You should evaluate every candidate table against a set of rigorous criteria. Do not simply pull every table in a database schema just because it is available.
Data Granularity
Granularity refers to what each row in a table represents. For example, a Sales_Transactions table might have a grain of "individual line item," while a Daily_Sales_Summary table might have a grain of "total sales per day." You must select the table with the lowest (most granular) level of detail that covers your requirements. If you select a table with a higher grain, you lose the ability to perform detailed analysis, such as identifying individual customer behavior patterns.
Data Latency and Freshness
How often is the table updated? If your business requirement is real-time dashboards, a table that updates via a batch process every 24 hours is a poor choice, regardless of its data quality. Conversely, if you are building monthly financial reports, you do not need the overhead of a real-time streaming source. Match the table's update frequency to the business need.
Data Integrity and Completeness
Check for null values, missing records, and default values that hide data gaps. A table might look perfect in the documentation, but if 40% of the Customer_ID fields are null, it is effectively useless for joining with other datasets. Always perform a "data profile" before committing to a table.
Business Context and Ownership
Who owns the data in this table? Is there a clear data dictionary? If a table is named temp_fix_v2_final, it is a massive red flag. Always prefer tables that are officially documented and supported by an engineering team. Tables created by individuals for ad-hoc analysis are high-risk and should be avoided in production pipelines.
Not read yet
Step-by-Step: The Selection Process
Selecting source tables is an iterative process. Do not try to do it all in your head. Follow this structured approach to ensure you haven't missed anything.
Step 1: Define the Business Question
Start by clearly stating what you want to achieve. For example: "I want to calculate the total lifetime value (LTV) of our customers." Once the goal is defined, list the entities involved: Customer, Order, Payment, and Subscription.
Step 2: Discover the Data
Use your organization’s data catalog or query the information schema of your source databases to find tables that correspond to these entities.
-- Example: Querying information schema to find relevant tables in a PostgreSQL database
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_schema = 'public'
AND (table_name ILIKE '%order%' OR table_name ILIKE '%customer%');
Review the results to see which tables contain the fields you need (e.g., customer_id, order_amount, transaction_date).
Step 3: Profile the Data
Before you write your ETL logic, run a quick audit of the candidate tables. You want to know the volume of data and the distribution of values.
-- Checking for missing values in a critical join key
SELECT count(*) AS total_rows,
count(customer_id) AS non_null_customers
FROM raw_orders;
If non_null_customers is significantly lower than total_rows, you know you have a data quality issue that must be addressed during the transformation phase.
Step 4: Map the Relationships
Create a simple Entity Relationship Diagram (ERD) or a mapping document. This documents how your selected tables will be joined. If you find you cannot join table A to table B because there is no common key, you have identified a gap in your source selection.
Not read yet
Common Pitfalls and How to Avoid Them
Even experienced engineers fall into traps when selecting source tables. Here are some of the most common mistakes and how to avoid them.
Pitfall 1: The "Everything" Approach
Many people try to pull every column from every table, thinking, "We might need this later." This leads to bloated pipelines, increased storage costs, and slower query performance.
- The Fix: Use a "Needs-Based" approach. Only pull the columns required to answer your current business question. You can always add columns later if the requirements change.
Pitfall 2: Relying on Obsolete Tables
Systems evolve. Sometimes a new version of a table is created (e.g., orders_v2), but the old one is left in the database.
- The Fix: Always verify the "last updated" timestamp of a table. If a table hasn't been modified in months, it is likely deprecated. Reach out to the team that manages the source system to confirm which table is the current standard.
Pitfall 3: Ignoring Hidden Business Logic
Sometimes, a table is not just a raw dump of data but a result of a stored procedure or a view that contains complex logic. If you query the underlying base table instead of the view, you might miss important filtering logic (like excluding test accounts or refunded orders).
- The Fix: Always check if there is an existing view or API that provides the data in the format the business expects. If you must go to the raw base tables, ensure you replicate the necessary business logic in your own transformation layer.
Note: The Danger of "Shadow IT" Data Avoid using tables generated by ad-hoc reports or local spreadsheets that have been uploaded to a database. These lack the rigorous schema management of official systems and are prone to breaking without warning. Stick to official, production-grade tables whenever possible.
Not read yet
Best Practices for Data Mapping
When you are ready to map your chosen tables to your unified schema, follow these industry-standard practices to ensure your work is maintainable and scalable.
Use Descriptive Naming Conventions
When you bring data into your unified environment, do not use the raw table names from the source (e.g., tbl_usr_01). Use clear, semantic names that describe the contents (e.g., dim_customers or fact_sales). This makes it easier for other team members to understand what the data represents without needing to consult a manual.
Versioning Your Mappings
Data sources change. A column might be renamed, or a data type might switch from integer to string. Always version control your mapping documentation (e.g., in a Git repository). If a pipeline breaks, you want to be able to look back and see exactly which version of the source mapping was in place.
Implement Data Validation Checks
During the unification process, implement checks to ensure the data you selected is behaving as expected.
- Row Count Checks: Compare the number of rows in the source to the number of rows in your unified table.
- Uniqueness Checks: Ensure that primary keys remain unique.
- Referential Integrity: Ensure that foreign keys in your unified dataset actually point to valid records in your dimension tables.
Documentation as Code
Do not keep your mapping documentation in a separate document that is never updated. Use tools that allow you to document your data directly within the code (such as dbt models). When you define a source, document it right there in the YAML file.
Callout: Why Normalization Matters in Unification While you might think that "everything in one big table" is easier for users, it is often a mistake. For analytical purposes, a Star Schema (a central fact table surrounded by dimension tables) is almost always better. When selecting source tables, think about how they will fit into this structure. Will this table act as a fact (measuring events) or a dimension (describing entities)?
Not read yet
Comparison of Source Types
When building a unification strategy, use this table to help you decide how to approach different source types:
| Source Type | Typical Handling | Key Challenge |
|---|---|---|
| Relational DB | Direct SQL Extraction | Managing complex joins |
| SaaS/API | Incremental Loading | Handling rate limits & pagination |
| Log Files | ETL/ELT Streaming | High volume, low signal-to-noise |
| Flat Files (CSV/Excel) | Manual Ingestion | Lack of schema enforcement |
Advanced Considerations: Handling Schema Drift
One of the most frustrating aspects of data unification is "schema drift." This happens when the structure of a source table changes unexpectedly. For example, an application update might change a column name or add a new mandatory field.
To manage this, you should implement a "Schema Registry" or at least a strict validation layer. If you use a tool like dbt or a custom Python-based pipeline, you can write tests that fail the pipeline if the source schema doesn't match your expectations.
# Conceptual example of a schema check
def validate_schema(source_df, expected_columns):
actual_columns = set(source_df.columns)
if not set(expected_columns).issubset(actual_columns):
missing = set(expected_columns) - actual_columns
raise ValueError(f"Schema mismatch! Missing columns: {missing}")
print("Schema validation passed.")
By failing early and loudly, you prevent corrupted data from flowing into your unified environment, which is much cheaper than fixing a dashboard that has been showing incorrect data for a week.
Not read yet
Managing Performance During Selection
When selecting tables, consider the performance impact of your choices. If you are joining several large tables across different databases, you will face significant latency.
Tip for Optimization:
- Filter Early: If you only need data for the last 30 days, ensure your source selection includes a filter on the date column. Do not pull the entire history of a table if you only need the most recent transactions.
- Use Indexes: If you have control over the source database, ensure that the columns you are using for joins are indexed. If you don't have control, talk to the database administrator to see if an index can be added to support your pipeline.
- *Avoid 'SELECT ': Always explicitly name the columns you need. This reduces the amount of data transferred over the network and makes your code more resilient to changes in the source table (like a new, massive column being added).
Not read yet
Common Questions (FAQ)
Q: Should I always use the most recent table version? A: Generally, yes. However, verify with the source system owners. Sometimes a "new" table is still in beta and might be missing data that the old table still captures.
Q: What if I have to join two tables from different databases? A: This is a common requirement in data unification. You will need to extract both tables into a common staging area (like a data lake or a cloud warehouse) before you can perform the join. Avoid trying to join across different database systems if possible, as it is slow and error-prone.
Q: How do I handle PII (Personally Identifiable Information)? A: When selecting source tables, always check if they contain PII. If they do, you must include a masking or anonymization step in your pipeline. Never move raw PII into a unified environment without a clear data governance policy.
Q: How often should I re-evaluate my source tables? A: At least once a year, or whenever there is a major change in the source application. Systems change, and what was the "correct" table twelve months ago might be obsolete today.
Not read yet
Conclusion: Key Takeaways
Selecting source tables is an architectural decision that dictates the quality and longevity of your data project. By following the principles outlined in this lesson, you can move from a reactive approach to a proactive, strategic data management style.
- Start with the Business Goal: Never select tables in a vacuum. Always anchor your selection in the specific business questions you need to answer.
- Prioritize Granularity: Always choose the most granular data available to maintain the flexibility of your analysis, but be mindful of the storage and performance costs.
- Verify the Source of Truth: Do not assume a table is the correct one simply because it exists. Confirm with stakeholders and documentation that the table is officially supported and authoritative.
- Automate Validation: Use automated tests to verify that your selected source tables meet your schema expectations. This is your first line of defense against data quality issues.
- Document Everything: Treat your mapping documentation as a living part of your codebase. If it isn't documented, it doesn't exist for the rest of the team.
- Filter Aggressively: Only pull the data you need. Explicitly select columns and apply date filters at the source to keep your pipelines fast and cost-effective.
- Plan for Change: Systems will evolve and schemas will drift. Build your pipelines with the expectation that the source will change, and use versioning and validation to handle those changes gracefully.
Mastering the selection of source tables is a hallmark of a senior data practitioner. It requires a blend of technical curiosity, business acumen, and a healthy dose of skepticism toward the data itself. As you progress in your career, you will find that the time spent "investigating the source" is the most valuable investment you can make in the success of your data unification projects.
Not read yet
Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.
No MB-260 practice exam yet
Your points already work on 76 Amazon, CompTIA and Microsoft exams.
See the exams