Data architecture interviews test more than definitions. Interviewers want to understand how you choose technologies, organize data, manage cost and performance, and keep downstream consumers reliable as an organization grows.
1. What is the difference between a data lake, data warehouse, and lakehouse?
Short answer: A data lake stores large amounts of data in flexible formats, a data warehouse provides a governed and optimized environment for analytics, and a lakehouse combines low-cost lake storage with warehouse-like management and query capabilities.
| Dimension | Data lake | Data warehouse | Lakehouse |
|---|---|---|---|
| Typical storage | Object storage with files such as JSON, CSV, Avro, and Parquet | Managed warehouse storage and tables | Often object storage plus a table format and catalog |
| Data types | Structured, semi-structured, and unstructured | Primarily structured and modeled data | Structured and semi-structured, with broader data workloads possible |
| Schema approach | Often schema-on-read, though governance can enforce schemas | Typically modeled and validated before serving | Schema enforcement and evolution depend on the table format and platform |
| Strengths | Flexible, scalable, economical storage | Reliable SQL analytics, governance, and performance | Open storage formats with transactional table features and analytics |
| Trade-offs | Can become a poorly governed data swamp | May create platform cost or data-copying constraints | Requires compatible table formats, catalogs, compute, and operational skills |
Example: A company lands application events in cloud object storage, transforms them into curated Parquet tables, and exposes trusted business metrics through a warehouse or lakehouse SQL engine.
2. Explain medallion architecture and its limitations.
Medallion architecture organizes data into progressively refined layers, commonly called Bronze, Silver, and Gold.
- Bronze: Raw or minimally processed source data, with ingestion metadata and replay capability where practical.
- Silver: Cleaned, validated, deduplicated, conformed data with consistent types and business keys.
- Gold: Business-ready aggregates, dimensional models, feature tables, and data products for specific consumers.
Source systems
|
v
Bronze: raw orders and customer events
|
v
Silver: validated orders, deduplicated events,
standardized customer identifiers
|
v
Gold: daily revenue, customer metrics,
finance reporting and ML features
Limitations and risks:
- Teams may treat the layers as a rigid rule even when a use case needs a different path.
- Repeated copies and transformations can increase storage, compute cost, and latency.
- Layer names do not provide data quality, lineage, access controls, or ownership by themselves.
- Gold tables can become overloaded with incompatible consumer-specific logic.
- Reprocessing and schema changes become difficult without clear contracts and versioning.
3. How would you design a data warehouse for a growing organization?
Start with business requirements and access patterns, then design for reliable ingestion, clear modeling, governance, performance, and operational support.
- Gather requirements: Identify consumers, use cases, freshness targets, data volume, query patterns, regulatory constraints, and recovery objectives.
- Build ingestion: Choose batch, CDC, or streaming per source. Make loads idempotent and track source offsets, watermarks, and run metadata.
- Separate layers: Keep raw or staging data, reusable intermediate transformations, and consumer-facing marts logically distinct.
- Model for analytics: Define business processes, grain, facts, dimensions, keys, history handling, and shared metric definitions.
- Optimize access: Use partitioning, clustering, indexes, materialized views, or aggregates where supported and justified by workload.
- Govern and secure: Apply least privilege, sensitive-column controls, lineage, catalog metadata, quality tests, and retention rules.
- Operate reliably: Monitor freshness, failures, cost, data volume, schema changes, and SLA compliance. Design replay and backfill procedures.
- Scale organizationally: Establish domain ownership, naming conventions, CI/CD, code review, documentation, and clear support responsibilities.
Example: For finance and sales analytics, use CDC or scheduled ingestion into staging, reusable transformations for conformed customers and products, and marts for revenue, forecasting, and planning. Apply role-based access and test reconciliations against source totals.
4. What are the differences between partitioning and clustering?
Both can reduce the amount of data scanned, but they organize data differently. Exact behavior depends on the database or query engine.
| Aspect | Partitioning | Clustering / sorting |
|---|---|---|
| Organization | Divides a table into distinct partitions using a partition key or range | Organizes data within a table or partition based on selected columns |
| Best fit | Commonly date, time, or another coarse-grained filter | Frequently filtered or joined columns with useful value locality |
| Query benefit | Partition pruning can skip entire partitions | Clustering or data skipping can reduce blocks or files scanned |
| Trade-off | Too many tiny partitions can add metadata and management overhead | May require maintenance or reclustering; benefit depends on data distribution and workload |
CREATE TABLE analytics.orders
PARTITION BY DATE(order_timestamp)
CLUSTER BY customer_id, region AS
SELECT *
FROM staging.orders;
This example partitions by order date and clusters by customer and region. A query filtering on the date can prune partitions; filters on clustered columns may further reduce the data scanned. Syntax and supported combinations vary by platform.
5. When would you use a materialized view?
A materialized view stores the result of a query so consumers do not need to recompute the full result on every read. It is useful when an expensive query is repeated often and the platform can keep the stored result acceptably fresh.
Good use cases:
- Repeated dashboards over large fact tables.
- Common aggregations such as daily revenue by region.
- Precomputed joins or summaries used by multiple consumers.
- Workloads where predictable query latency matters more than immediate recomputation.
Trade-offs: Storage and refresh cost, refresh latency, restrictions on supported SQL, and the risk of serving stale results. Some platforms incrementally maintain materialized views; others refresh them differently or have specific eligibility rules.
CREATE MATERIALIZED VIEW analytics.daily_revenue AS
SELECT
order_date,
region,
SUM(net_amount) AS revenue
FROM analytics.orders
GROUP BY order_date, region;
Decision rule: Consider a materialized view when the query is expensive, reused frequently, and can tolerate the refresh semantics. Compare it with caching, summary tables, or ordinary views for your platform.
6. What is a semantic layer, and why is it useful?
A semantic layer defines business concepts and metrics in a consistent, reusable way on top of underlying data models. It maps technical tables and columns to concepts such as revenue, active customer, churn, or gross margin.
Why it matters:
- Consistency: Teams use the same metric definitions instead of rewriting slightly different SQL.
- Self-service analytics: Analysts and business users can explore data using business-friendly names.
- Governance: Central definitions can incorporate joins, filters, access policies, and metric documentation.
- Maintainability: Changes to physical tables can sometimes be absorbed without changing every consumer query.
Example: Define “Net Revenue” once as the agreed sum of order value minus discounts and refunds, with a documented currency and date policy. Finance and sales dashboards then reuse the same definition.
7. How would you organize data across staging, intermediate, and mart layers?
A common transformation design separates source-aligned preparation from reusable business logic and consumer-facing models.
| Layer | Purpose | Typical conventions |
|---|---|---|
| Staging | Standardize source data with minimal business transformation | One model per source entity; rename columns, cast types, normalize timestamps, preserve source keys |
| Intermediate | Encapsulate reusable transformations and business logic | Deduplication, joins, business rules, conformed entities, reusable calculations |
| Marts | Serve specific business processes or consumers | Facts, dimensions, aggregates, finance or sales models, documented metric grain |
models/
staging/
salesforce/
stg_salesforce__accounts.sql
stg_salesforce__opportunities.sql
intermediate/
int_opportunities__enriched.sql
int_accounts__conformed.sql
marts/
sales/
fct_opportunities.sql
dim_account.sql
mart_pipeline_forecast.sql
finance/
mart_revenue_summary.sql
Best practices:
- Document the grain, keys, owner, and intended consumers of each model.
- Add tests for uniqueness, not-null constraints, relationships, accepted values, and business reconciliations.
- Keep staging close to the source; avoid embedding downstream-specific reporting logic there.
- Use intermediate models for logic that is genuinely reusable, not simply to create more layers.
- Control access at the appropriate layer and avoid exposing raw sensitive data to every consumer.
8. What is Data Mesh, and when does it make sense?
Data Mesh is an organizational and architectural approach that treats data as a product owned by domain teams, supported by self-serve data infrastructure and federated governance.
Its commonly described principles are:
- Domain-oriented ownership: Teams closest to the business domain own and maintain its data products.
- Data as a product: Data products have discoverability, documentation, quality expectations, access mechanisms, and support commitments.
- Self-serve data platform: A platform team provides reusable infrastructure, deployment patterns, observability, and common capabilities.
- Federated computational governance: Shared standards for security, interoperability, privacy, and compliance are applied across domains.
When it makes sense: Multiple domains have meaningful autonomy, a central data team is a bottleneck, and the organization can invest in platform capabilities, product ownership, and governance.
When it may not: A small organization with a few pipelines may gain more from a centralized team and simple standards. Mesh can otherwise create duplicated tooling, inconsistent definitions, and unclear accountability.
Key distinction: Data Mesh is not a storage technology or a synonym for a lakehouse. It is primarily about ownership, product thinking, platform enablement, and governance.
9. How do data contracts help prevent downstream pipeline failures?
A data contract is an explicit agreement between a data producer and its consumers about the structure, meaning, quality, delivery behavior, and ownership of a dataset or event.
A useful contract may define:
- Schema: Field names, types, nullability, required fields, and allowed schema changes.
- Semantics: Business meaning, units, timezone, identifiers, and field-level definitions.
- Quality rules: Uniqueness, valid ranges, referential integrity, and completeness expectations.
- Operational expectations: Freshness, availability, volume anomalies, delivery cadence, and incident response.
- Ownership and change policy: Contact, versioning, compatibility rules, deprecation periods, and communication process.
How it prevents failures:
- Validate incoming data against the contract during ingestion or CI/CD.
- Reject, quarantine, or flag incompatible changes before they silently corrupt downstream tables.
- Run data quality checks and alert owners when freshness or quality thresholds are breached.
- Use versioning and a deprecation window for breaking changes.
- Trace dependencies so affected consumers can be notified and tested before deployment.
dataset: sales.orders
owner: sales-data-platform
version: 2
fields:
- name: order_id
type: string
required: true
unique: true
- name: order_timestamp
type: timestamp
required: true
- name: net_amount
type: decimal
required: true
description: Net order amount in the reporting currency
expectations:
freshness: "within 2 hours"
null_rate:
order_id: 0
net_amount: 0
change_policy:
breaking_changes: "new major version and consumer notice"
Example failure prevented: A producer renames net_amount or changes its meaning from “after discount” to “before discount.” Contract validation and versioned change management can catch the incompatibility before a finance dashboard reports incorrect revenue.
Quick Revision Table
| Topic | One-line takeaway |
|---|---|
| Lake vs warehouse vs lakehouse | Flexible storage vs managed analytics vs lake storage with table-management capabilities. |
| Medallion architecture | Raw → cleaned/conformed → business-ready, with quality and ownership across layers. |
| Warehouse design | Start from workloads and SLAs; then model, govern, optimize, and operate. |
| Partitioning vs clustering | Partitions skip larger segments; clustering improves locality or data skipping within them. |
| Materialized view | Precompute frequently reused expensive queries when refresh behavior is acceptable. |
| Semantic layer | Centralize shared business metrics and definitions. |
| Staging/intermediate/marts | Prepare source data, reuse transformations, and serve consumer-ready models. |
| Data Mesh | Domain-owned data products enabled by self-service infrastructure and federated governance. |
| Data contracts | Make schema, semantics, quality, and operational expectations explicit and testable. |
Scenario-Based Practice Questions
Try answering these out loud before opening the suggested approach.
Scenario 1: Your analytics costs are rising rapidly. What would you investigate?
Review query history and cost by team, model, and workload. Look for full scans, inefficient joins, repeated transformations, unbounded dashboard queries, and unnecessary refreshes. Evaluate partition pruning, clustering, incremental processing, aggregates or materialized views, file sizing, retention, and workload scheduling. Establish cost attribution and regression monitoring, then measure changes against representative queries.
Scenario 2: A source team changes a field type without warning and breaks several dashboards. How do you prevent a repeat?
Introduce a producer-consumer contract with schema compatibility rules, automated validation, CI checks, versioning, and an agreed deprecation process. Add lineage to identify downstream dependencies, alert the owner on violations, and quarantine incompatible data where appropriate. Document incident response and test the change with consumers before rollout.
Scenario 3: A company has only four data engineers. Should it adopt Data Mesh?
Probably not as a full organizational transformation yet. Start with clear domain ownership, documented data products, common quality standards, and a small set of self-service capabilities. A centralized team may be more efficient at this size. Revisit broader mesh practices when domain scale and coordination bottlenecks justify the operating cost.
Scenario 4: Business teams report different revenue numbers. How would you solve it?
Agree on the business definition, grain, currency conversion, treatment of refunds and discounts, and time attribution with finance stakeholders. Publish one governed metric through a semantic layer or shared mart, document its owner and lineage, add reconciliation tests, and migrate consumers away from conflicting local calculations.
Chapter Summary
- Compare architectural patterns by workload, governance, performance, and operating cost.
- Use medallion layers as clear responsibilities, not as mandatory extra copies.
- Design warehouses around business requirements, modeling, reliability, and security.
- Optimize partitioning, clustering, and materialized views using workload evidence.
- Use semantic layers and well-structured models to keep business logic consistent.
- Adopt Data Mesh when domain ownership and platform maturity justify the complexity.
- Make data contracts executable through automated checks and change management.
Practice Challenge
Design a data platform for a company that ingests sales events every few minutes and produces finance reports and ML features. Explain your storage architecture, data layers, partitioning strategy, ownership model, quality controls, and how you would handle a breaking source-schema change.
Comments
Post a Comment