Lesson 04 — Data Architecture & Storage Design
Course: Solution Architecture & System Design (sad) | Group: Data Engineering | Lesson ID: sad4
Lesson opener
In one line: Data architecture decides where facts live, how they are governed, and which store fits each access pattern — not one database for everything.
Why it matters: Putting every workload in one store creates silent performance and governance debt that shows up as blocked decisions and expensive rewrites.
Before this lesson: Architecture Patterns & Design Principles and Requirements Analysis & System Thinking. Helpful: Warehouses vs lakes, Warehouses, Lakes & Lakehouse, Why governance matters.
Workplace scenario — Northline Consumer Goods and Northline Financial: Both organisations are growing their data footprints. Northline Consumer Goods needs to decide where to store order data, inventory events, and customer analytics. Northline Financial needs to store loan application records, audit trails, and risk-model training inputs. You are the solution architect advising both teams on where data belongs and why.
What You Will Be Able to Do
By the end of this lesson you will be able to:
- Classify a data use case across five storage paradigms: operational (OLTP) relational database, document store, data warehouse (OLAP), data lake, and lakehouse.
- Apply an architecture decision framework to choose between storage options for a given set of requirements.
- Explain the architectural relationship between storage layers and the data flows that connect them.
- Describe the governance concerns — ownership, lineage, access control, retention, deletion — that must be addressed at each storage layer.
- Identify when a lakehouse is and is not the right choice compared to a separate lake + warehouse.
- Produce a Data Architecture Decision table and at least two ADRs for a realistic multi-layer scenario.
Deliverable: A Data Architecture Decision table for Northline Consumer Goods covering at least four distinct data use cases, with ADRs for the two most architecturally significant decisions.
Prerequisites
| Topic | Where to review |
|---|---|
| Architecture patterns and ADRs | Architecture Patterns & Design Principles |
| Functional and non-functional requirements | Requirements Analysis & System Thinking |
| Warehouses vs data lakes | Data Engineering — Warehouses vs Lakes |
| Data architecture and infrastructure | Data Architecture & Infrastructure |
| Data governance: ownership, lineage, classification | Data Governance — Lesson 1 |
Plain English: Storage Paradigms
The fundamental tension: OLTP vs OLAP
All storage decisions begin with one question: is this data being written and read in small, fast transactions (OLTP — Online Transaction Processing) or aggregated and analysed in bulk across large volumes (OLAP — Online Analytical Processing)?
| Dimension | OLTP | OLAP |
|---|---|---|
| Primary operations | INSERT, UPDATE, single-row SELECT | GROUP BY, aggregations, range scans over millions of rows |
| Concurrency | Thousands of short transactions per second | Tens of complex queries per hour |
| Data currency | Always current | Typically refreshed in batches (minutes to hours) |
| Schema style | Normalised (3NF or higher) | Denormalised (star or snowflake schema) |
| Consistency model | ACID — atomicity, consistency, isolation, durability | Eventual (batch refresh) or read-consistent snapshot |
| Example | PostgreSQL orders table | BigQuery or Snowflake orders fact table |
The architecture mistake: using an OLTP database for both transactional and analytical workloads. An analyst running SELECT product_id, COUNT(*), SUM(total) FROM orders GROUP BY 1 across 50 million rows on the production PostgreSQL instance competes with checkout writes for buffer pool and CPU. In development with a hundred rows this is invisible. In production it causes lock contention and degraded checkout performance exactly when business pressure is highest.
Paradigm 1 — Relational (OLTP) Database
A relational database stores data in tables with enforced schemas and provides ACID transaction guarantees. It is the right choice for:
- Transactional data requiring consistency: orders, payments, loan applications, inventory adjustments.
- Systems where referential integrity matters: a foreign key between
order_lines.order_idandorders.id. - Workflows where a set of operations must atomically succeed or fail: decrementing stock and recording an order in the same transaction.
Examples: PostgreSQL 16, MySQL 8.0, SQL Server 2022. (Pricing and licensing are version- and environment-dependent — check vendor documentation.)
Scaling patterns: Vertical scaling (larger instance) handles moderate growth. A read replica absorbs read-heavy reporting queries while protecting the primary. Connection pooling (PgBouncer for PostgreSQL) reduces connection overhead at high concurrency. Horizontal write sharding is complex and typically a last resort justified by write throughput requirements that a single primary genuinely cannot meet.
When not to use: When the query pattern is dominated by large aggregations over historical data. When a table scan of millions of rows is the normal query shape, not the exception.
Paradigm 2 — Document Store
A document database stores semi-structured documents (typically JSON or BSON). It is the right choice for:
- Data with a variable or evolving schema: a product catalogue where a "shirt" has
sizeandcolourattributes but a "laptop" hasRAMandCPU— a rigid relational schema is awkward for this. - High-read, moderate-write workloads where a document is retrieved as a whole unit.
- Hierarchical data that is always accessed together and never joined across documents.
Examples: MongoDB 7.x, Amazon DocumentDB (MongoDB-compatible API — confirm feature parity before adopting), CouchDB. (Pricing: environment-dependent.)
When not to use: When complex joins across document types are required (joins push to the application layer — expensive and error-prone). When referential integrity across collections matters. When the schema is actually stable and well-understood — a relational database handles that better.
Paradigm 3 — Data Warehouse (OLAP)
A data warehouse is an OLAP system optimised for analytical queries over large volumes of historical integrated data. Data is loaded from operational systems via ETL or ELT pipelines, cleansed, and stored in a dimensional schema (star or snowflake) that favours fast aggregation.
For architectural depth on warehouses and their internal design see Data Engineering — Warehouses vs Lakes and Data Architecture & Infrastructure. This lesson focuses on when a warehouse is the right architectural choice:
- Business intelligence and self-service reporting workloads requiring SQL access by analysts.
- Historical trend analysis across large data volumes (months or years of history).
- When data from multiple operational source systems must be integrated and reconciled for a single analytical view.
- When analyst queries must be isolated from the production OLTP system to protect operational performance.
Examples: Snowflake, Google BigQuery, Amazon Redshift, Azure Synapse Analytics. (Pricing models — storage-based, compute-based, query-based — vary significantly across products and between on-demand and reserved capacity; evaluate against your specific query patterns, data volume, and concurrency requirements. All pricing is environment-dependent.)
Architectural relationship to OLTP: The warehouse is always downstream of operational systems. Data flows: OLTP source → ETL/ELT pipeline → warehouse. The warehouse reflects the source of truth; it is never the source of truth itself. If the warehouse and the OLTP system disagree, the OLTP system is correct.
Paradigm 4 — Data Lake
A data lake is a storage repository holding large volumes of data in native or minimally transformed format — structured, semi-structured, and unstructured — on low-cost object storage (Amazon S3, Azure Blob Storage, Google Cloud Storage).
For architectural depth on lake zone design and processing patterns see Data Engineering — Warehouses vs Lakes.
When a data lake is the right architectural choice:
- You need to store raw data before you know all the downstream use cases it must serve (schema-on-read — schema is applied at query time, not at write time).
- You need to store unstructured data: logs, images, PDF documents, audio, video.
- Cost-effective, long-term retention of large data volumes — object storage costs are orders of magnitude lower than managed database storage per GB.
- Machine learning feature engineering and model training that needs raw or lightly processed historical data with large-scan access patterns.
When a data lake is the wrong choice:
- As the primary store for operational transactional data — object storage has no ACID guarantees at the file level.
- When analysts need to query data with SQL interactively — without a query engine layer (Athena, BigQuery over GCS, Trino, Spark SQL) the lake is not directly queryable.
- When data quality and schema governance are not enforced — a lake without governance becomes a data swamp: files accumulate, nobody knows what is reliable, and compliance requirements become impossible to fulfil.
Paradigm 5 — Lakehouse
The lakehouse combines the cost economics and storage flexibility of a data lake with the query performance, ACID transaction support, and governance capabilities typically associated with a data warehouse. This is achieved through open table formats — Apache Iceberg, Delta Lake, Apache Hudi — that add transactional semantics on top of object storage files (Parquet).
For technical depth on open table formats see Data Architecture & Infrastructure. This lesson focuses on architectural positioning:
When a lakehouse is appropriate:
- You want a single storage layer that serves both data science (ML, raw-data access, Python/Spark workflows) and BI (SQL analytics by analysts) workloads, eliminating the duplication of a separate lake and warehouse with ETL between them.
- You need ACID-capable operations on large datasets — upserts for incremental loads, deletes for GDPR right-to-erasure compliance — without the cost of a full-featured data warehouse.
- Your team has the operational skills to manage open table format metadata (compaction, snapshot expiry, schema evolution).
Caveats and honest limitations:
- Query performance for highly concurrent BI workloads (many analysts running simultaneous complex queries) may not match a purpose-built columnar warehouse with dedicated compute. Benchmark against your specific workload.
- The open table format ecosystem is evolving — evaluate tooling support for your chosen query engines (Spark, Trino, Athena, BigQuery Iceberg support, Databricks — availability and feature completeness vary by version and service).
- "Exactly-once" or "guaranteed delivery" claims in distributed systems always depend on configuration and failure modes; validate idempotency requirements for your specific workload.
Storage paradigm comparison:
| Paradigm | Write pattern | Read pattern | Best for | Not for |
|---|---|---|---|---|
| OLTP (relational) | Many small, frequent writes | Small precise reads and joins | Transactional systems, referential integrity | Large analytical scans |
| Document store | Moderate writes of whole documents | Whole-document retrieval | Variable schema, hierarchical data | Complex cross-document joins |
| Data warehouse | Batch bulk load (ETL/ELT) | Large aggregations and scans | BI, self-service reporting, historical analysis | Real-time transaction processing |
| Data lake | Batch or streaming ingest | Batch scans, ML feature access | Raw storage, ML training, long-term retention | Direct interactive SQL without a query engine |
| Lakehouse | Batch and streaming ingest | Analytical + ML in one layer | Unified analytics platform, GDPR-capable lake | Highest-concurrency BI without benchmarking |
Governance at the Storage Layer
Storage decisions are not purely technical. Each storage layer has governance implications. For the full governance framework see Data Governance — Lesson 1. Architecturally, the following governance concerns must be addressed at design time — retrofitting them is expensive.
Data ownership: Who is the accountable owner of data in each storage layer? The order OLTP database is owned by the order management team — they approve schema changes and are responsible for data quality. The analytics warehouse is owned by the data engineering team. Ownership determines who is paged when data is wrong.
Data lineage: Where did this data originate? What transformations were applied between source and current location? Lineage becomes critical when a report shows unexpected numbers and the root cause must be traced. Modern data catalogues (Apache Atlas — open source; commercial options available — check current vendor offerings) capture lineage metadata.
Access control: Who can read or modify data in each layer? Column-level masking (exposing an orders table to analysts with email masked to sha256(email)) must be designed at the storage layer. Row-level security (a supplier sees only their own purchase orders) is a storage-layer constraint, not an application-layer nicety.
Data retention: How long is data retained in each layer? OLTP may retain 2 years of active data; the warehouse 7 years of history; the data lake indefinitely at low object-storage cost. Retention policies must align with applicable regulatory requirements — confirm exact periods with legal for each data classification. Policies vary by jurisdiction and data type.
Deletion capability (GDPR and equivalent): The right to erasure requires that personal data can be deleted on request across all layers where it exists. This must be designed for at architecture time:
- OLTP:
DELETEor soft-delete + hard-delete job. - Warehouse:
DELETEstatement on supported warehouse engines; some warehouse products have limitations on DML — verify. - Data lake (raw Parquet): deletion requires rewriting files. Open table formats (Iceberg
MERGE INTO, Delta LakeDELETE) make this tractable at scale. - Design the deletion workflow across all layers before the first byte of PII is ingested.
Teacher Walkthrough: Architecture Checklist for Data Architecture
| Checklist item | Northline Consumer Goods |
|---|---|
| Business objective | Enable real-time order management; analyst self-service on historical data; ML demand forecasting |
| Scale assumptions | 5,000 orders/day; ~300,000 order line items/month; 50 analysts; ML training weekly batch |
| Data sources | Shopify (D2C orders), SAP ERP (inventory, suppliers), WMS (fulfilment), DHL (carrier status) |
| Volume / velocity | Order events: ~10/min; inventory: hourly sync; carrier webhooks: up to 50/sec |
| Storage decisions | Orders: PostgreSQL 16 (OLTP); events: append-only; analytics: cloud data warehouse; ML: data lake |
| Processing | ELT from OLTP to warehouse (daily batch); streaming ingest of carrier events to lake |
| AI / ML | Demand forecasting: weekly batch training on lake data; model serving separate from data storage |
| Security | PII masking in warehouse; row-level security in analyst access layer; encryption at rest and in transit |
| Monitoring | OLTP replication lag; ETL job duration and row-count reconciliation; warehouse data freshness |
| Failure handling | ETL failure → stale warehouse data → dashboard freshness banner; OLTP primary failure → read-replica promotion |
| Cost | Object storage (lake): low cost per GB; warehouse: compute usage-based; all pricing environment-dependent |
| Validation | OLTP: integration tests; ETL: source/target row-count hash reconciliation; warehouse: data quality checks on key metrics |
Worked Example 1 — Northline Consumer Goods: Data Architecture Decision Table
Data use case mapping
| Use case | Data type | Access pattern | Latency / freshness requirement | Recommended storage |
|---|---|---|---|---|
| Order creation and management (checkout) | Transactional, structured | High-frequency small reads and writes; ACID required | < 100 ms write latency; always current | PostgreSQL 16 (OLTP) |
| Carrier webhook events (status updates) | Semi-structured, append-only | Write-heavy; rarely re-read individually; aggregated for dashboards | Near-real-time ingest; queried in batch | Append-only event log (PostgreSQL table or object storage) |
| Analyst sales and returns reporting | Historical aggregates | GROUP BY, date-range filters, joins across orders/products/customers; 50 concurrent analysts | Stale up to 4 hours acceptable | Cloud data warehouse (e.g., BigQuery, Snowflake — pricing environment-dependent) |
| Product catalogue (variable attributes by category) | Semi-structured JSON | Full document retrieval by product_id; ~10 ms P95 | Current; updated by merchandising team | JSONB column in PostgreSQL or dedicated document store depending on update frequency |
| ML demand forecasting training data | Historical events, raw | Large scans; weekly batch training; Python/Spark access | Weekly freshness acceptable; 2 years of history needed | Data lake (object storage, partitioned by date) |
| GDPR deletion request fulfilment | Cross-layer PII | Asynchronous; 30-day SLA typical (confirm with legal) | Asynchronous — not on critical path | Orchestrated deletion workflow: DELETE on OLTP; warehouse DML; Iceberg MERGE on lake |
Data flow diagram (text)
D2C Orders (Shopify)
│
▼
Order Service
│
▼
PostgreSQL 16 (OLTP) ─────────────── ELT pipeline (daily) ──────▶ Cloud Data Warehouse
[Orders, Customers, [Analyst SQL access,
Order Lines] dashboards, BI tools]
DHL Carrier Webhooks
│
▼
Event Ingestor
│
▼
Object Storage (Data Lake)
[Partitioned Parquet: year/month/day]
│
├─── Spark / dbt weekly batch ──▶ ML Feature Tables (Iceberg)
│ [Demand forecasting training]
│
└─── streaming query ──────────▶ Operational delivery dashboardArchitecture Decision Records
ADR-004: Separate OLTP and OLAP workloads — dedicated data warehouse for analytics
Status: Accepted
Context: 50 analysts running ad-hoc GROUP BY queries against the production PostgreSQL
instance degrade transactional performance for the checkout path.
OLTP and OLAP access patterns are fundamentally incompatible at this scale.
Decision: Establish a cloud data warehouse as the analytical layer.
Data flows from PostgreSQL via daily ELT job (source row count reconciled
against target at each run). Analysts access the warehouse, never the OLTP DB.
Consequences:
+ Analyst queries do not compete with production checkout writes.
+ Warehouse is optimised for OLAP — query performance for aggregations is orders of
magnitude faster than OLTP.
- Data in the warehouse is up to 4 hours stale. Dashboard must show last-refresh timestamp.
- Additional ELT pipeline to build, monitor, and maintain.
Risk: ELT job failure → warehouse becomes stale beyond SLA → alert on job failure;
add dashboard banner when data age exceeds 4 hours.ADR-005: Data lake on object storage with Iceberg for ML and GDPR-capable transformations
Status: Accepted
Context: ML demand forecasting requires 2 years of raw event history not available in the
warehouse schema. Weekly training batches require large sequential scans.
GDPR deletion requires the ability to delete individual records from historical
lake data — not possible with raw Parquet files without rewriting partitions.
Decision: Ingest carrier events and order events to object storage (data lake), partitioned
by year/month/day. Apply Apache Iceberg on top of the raw zone for tables that
require GDPR deletion or upsert capability. Use Spark or a managed query service
for ML feature engineering.
Consequences:
+ Cost-effective long-term retention (object storage cost per GB is substantially lower
than managed DB or warehouse storage — environment-dependent; confirm with FinOps).
+ GDPR deletion via Iceberg MERGE/DELETE without rewriting entire partitions.
+ ML team accesses raw and processed data in a single storage layer.
- Team must develop operational competency in Iceberg metadata management (compaction,
snapshot expiry).
- Interactive BI query latency on the lake is higher than on the warehouse; BI users
remain on the warehouse.
Risk: Open table format ecosystem is evolving — pin Iceberg version in build tooling;
document upgrade process in ADR.Worked Example 2 — Northline Financial: Data Architecture for Loan Origination
Northline Financial needs storage decisions for five distinct data concerns:
| Use case | Storage | Rationale |
|---|---|---|
| Live loan application records | PostgreSQL 16 (OLTP) | ACID transactions; loan state machine requires row-level locking and referential integrity; 20 concurrent loan officers |
| Audit trail of state transitions | Append-only audit table (PostgreSQL, separate schema) | Immutable record; no UPDATE/DELETE ever permitted on audit rows; queries are infrequent point-lookups |
| Credit bureau responses (Equifax API v3.0) | JSONB column on the application record (PostgreSQL) | Responses are semi-structured, < 1 MB per record, always retrieved alongside the application; no independent querying needed |
| Risk model training data | Data lake (object storage) | Large historical dataset; accessed weekly by the ML team using Python; 3+ years of application history; would be prohibitively expensive in a managed DB |
| Regulatory reporting | Data warehouse (scheduled export from PostgreSQL) | Annual summary reports; low concurrency; clean separation from OLTP; alternative: direct DB extract at current low volume — review when volume grows |
Audit trail implementation
The audit trail is append-only — a fundamental governance constraint, not a design preference.
-- Append-only audit table: application-level constraint enforced
-- Grant only INSERT to the application role; no UPDATE or DELETE.
CREATE TABLE application_audit (
audit_id BIGSERIAL PRIMARY KEY,
application_id UUID NOT NULL,
changed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
changed_by TEXT NOT NULL, -- authenticated actor ID from Okta
old_status TEXT,
new_status TEXT NOT NULL,
note TEXT,
checksum TEXT -- SHA-256 of (application_id||changed_at||old_status||new_status)
-- for lightweight tamper detection; not a cryptographic proof
);
-- Role granted to application service: INSERT only
GRANT INSERT ON application_audit TO loan_app_service;
-- No GRANT UPDATE or DELETE — enforced at DB level, not just application levelThe checksum column supports a periodic batch job that verifies row integrity. This is a standard, lightweight tamper-detection pattern — not a blockchain. Confirm with the compliance team whether this satisfies their audit integrity requirement before finalising.
PII handling across layers
Loan application records contain financial PII (applicant name, national ID number, income). This PII must be subject to:
- Access control in OLTP: Only the assigned loan officer and their manager may read a full application record.
- Masking in the data lake: Before application data flows to the risk model training lake, PII must be pseudonymised (e.g., replace national ID with a deterministic hash using a secret key; replace name with a synthetic value). The ML model trains on financial signals, not on identity.
- Retention across layers: OLTP and audit table: statutory minimum (confirm with legal — UK mortgage records retention is jurisdiction-specific). Data lake: same retention limits apply to PII even in pseudonymised form; document the pseudonymisation scheme so re-identification risk can be assessed.
Failure Case: The Data Swamp
Symptoms
Northline Consumer Goods ingests operational data into an S3-based data lake from day one of a data modernisation programme. Two years later:
- Analysts cannot find data. Files are named
final_orders_REAL_v3_use_this_one.parquet. Nobody knows which version is authoritative. - Nobody can answer "who owns the product catalogue dataset" — three teams each claim it belongs to another.
- A GDPR deletion request arrives for a customer. The data engineering team spends three weeks searching S3 prefixes for all files that might contain the customer's data. They find some. They are not certain they found all.
- An ML training pipeline fails silently when a source CSV schema changed (a
product_categorycolumn was renamedcategory_code) without any notification.
Root-cause diagnosis
The data lake was treated as a storage cost optimisation, not as an architectural component requiring governance. No data catalogue was implemented. No schema registry. No naming or partitioning conventions. No data ownership assignments. No lineage tracking. Raw file ingestion from multiple teams without coordination. The lake became a data swamp.
Correction
- Data catalogue: Implement a metadata catalogue (AWS Glue Data Catalog, Apache Atlas, or a managed commercial option — evaluate against team skills and tooling ecosystem; pricing environment-dependent) to register every dataset with: owner, schema, freshness SLA, sensitivity classification, source lineage.
- Open table format adoption: Migrate structured datasets to Apache Iceberg or Delta Lake. This enables: schema evolution tracking, ACID-capable MERGE/DELETE for GDPR, time travel for auditing historical states, and consistent metadata for the catalogue.
- Naming and partitioning conventions: Establish and enforce a convention — for example
s3://northline-lake/{domain}/{entity}/year={YYYY}/month={MM}/day={DD}/. No free-form file naming. - Data ownership: Assign an explicit owner (a named team, not an individual) to every registered dataset. The owner is accountable for schema change notifications, freshness SLA, and quality.
Validation after correction
- GDPR deletion request can be fulfilled within 72 hours using Iceberg
DELETE FROMon registered Iceberg tables, plusDELETEon the OLTP system — down from three weeks. - ML pipeline schema changes are caught by the schema registry before training jobs execute.
- Analysts locate any registered dataset via catalogue search in under 5 minutes.
Preventive controls
- Data governance framework applied before the lake is populated, not as a remediation activity (see Data Governance — Lesson 1).
- Schema registry for all streaming ingest (Avro or Protobuf schemas registered before first message; consumers fail fast on unregistered schema changes).
- ADR documents the open table format choice, the catalogue tooling decision, and the partitioning convention. New datasets require a catalogue registration PR before ingestion pipelines are deployed.
Guided Practice
Scenario
Northline Consumer Goods is launching a Customer Loyalty Programme. Data requirements to address:
- Customer loyalty points balance (read and written on every purchase and redemption).
- Points transaction history (every earn and redemption recorded; never modified after the fact).
- Customer tier analysis for marketing (which customers moved up or down a tier last month?).
- Personalisation ML model (trained monthly on full transaction history).
Stage 1 — For each of the four requirements, propose a storage paradigm and justify in one sentence (attempt before hints).
Hint 1: Points balance is updated on every transaction — what consistency guarantee is required? What happens if two purchases arrive simultaneously and the balance is decremented twice incorrectly?
Hint 2: Transaction history is append-only — nobody should ever edit a completed transaction. What does that imply for storage design?
Hint 3: Tier analysis needs historical aggregation across all customers. Which paradigm is optimised for that?
Stage 2 — Identify one data governance concern for this programme (attempt before hint).
Hint: Points transactions include purchase amounts linked to customer IDs. Who should be able to query individual-level transaction records?
Stage 3 — Write one ADR for the most architecturally significant decision.
Full Guided Solution
Storage paradigm mapping:
| Requirement | Storage paradigm | Justification |
|---|---|---|
| Points balance | PostgreSQL 16 (OLTP) with row-level locking | ACID required — no double-credit or double-spend under concurrent purchases |
| Transaction history | Append-only table (PostgreSQL, same instance) | Immutable by design; INSERT only, no UPDATE/DELETE; auditable; queried infrequently |
| Tier analysis (marketing) | Cloud data warehouse | Monthly aggregations over full customer history; analyst SQL; isolated from OLTP |
| ML personalisation training | Data lake (object storage) | Monthly batch training; large sequential scans; raw history; Python/Spark access |
Governance concern: Loyalty transaction records include purchase amounts linked to a customer ID. This is financial personal data. Access control: only the loyalty platform service has write access to the OLTP transaction table; marketing analysts access only aggregated tier distributions in the warehouse — individual-level transaction records require a data-access approval from the Data Governance team (see Data Governance).
ADR:
ADR-006: PostgreSQL for loyalty points balance with append-only transaction history
Status: Accepted
Context: Points balance requires ACID semantics — concurrent purchases from the same
customer must not result in double-credit or double-spend.
Transaction history must be immutable: completed transactions cannot be edited
or deleted (audit and dispute resolution requirement).
Decision: Points balance: PostgreSQL row, updated with optimistic locking
(version column incremented on each UPDATE; caller retries on conflict).
Transaction history: append-only table; application role has INSERT only —
no UPDATE or DELETE granted at the database level.
Consequences:
+ ACID guarantees on balance; no double-credit under concurrent load.
+ Immutable audit trail; tamper-evident at the database permission level.
- Transaction table grows unboundedly — partition by year; archive to object storage
after 2 years (retain queryable via Iceberg for ML and compliance).
Risk: Points balance contention under very high purchase concurrency (e.g., flash sale)
→ if PostgreSQL row lock contention is measured as a bottleneck, introduce a
Redis counter for real-time balance with async reconciliation to PostgreSQL.
Document this as a potential phase 2 architecture change; do not add the complexity
until it is needed.Independent Practice
Design the data architecture for a Northline Financial Credit Risk Dashboard: risk officers need daily summaries of the loan portfolio — total outstanding balance, default rate by product type, and vintage analysis (performance of loans originated in a given month). The underlying data comes from the loan origination PostgreSQL database.
Acceptance criteria / rubric:
| Criterion | Pass |
|---|---|
| Storage paradigm identified for each use case | Correct paradigm; justification tied to access pattern, not just naming a technology |
| OLTP/OLAP separation addressed | Explicit decision with rationale tied to workload characteristics; not assumed |
| Data flow described | Source → transformation type → target storage layer; all layers connected |
| At least one ADR | Status, Context, Decision, Consequences, at least one Risk |
| Governance concern identified | At least one of: access control, lineage, PII handling, or retention addressed |
| No invented compliance certifications | Any regulatory references qualified as "confirm with legal/compliance" |
Common Mistakes
- Using a single database for both transactional and analytical workloads. OLTP and OLAP have incompatible access patterns at scale. Analytical queries block transactional writes; transactional writes interrupt analytical scans. Separate them.
- Building a data lake without governance. A lake without a catalogue, data ownership, naming conventions, and schema management becomes a swamp within 12–18 months of real use.
- Defaulting to a lake + warehouse dual-layer when a lakehouse reduces complexity. If your team can operate open table formats and your workloads are a mix of SQL analytics and ML access, a lakehouse eliminates the ETL between the lake raw zone and the warehouse. Evaluate genuinely — don't add the lakehouse complexity if BI-only workloads dominate.
- Treating the data warehouse as the source of truth. The warehouse is a derived copy of the OLTP system, refreshed via ETL/ELT. If the warehouse and the OLTP database disagree, the OLTP system is correct. Never write operational data directly into the warehouse.
- Not designing for GDPR deletion at architecture time. Deletion capability added to an immutable lake after launch requires rewriting Parquet files (expensive) or adopting an open table format (significant migration). Design for it before the first byte of PII is ingested.
Five Quick Checks
Q1. What is the fundamental difference between OLTP and OLAP workloads, and why does this matter for storage selection?
A: OLTP handles many small, fast transactions (INSERT, UPDATE, single-row SELECT) requiring ACID guarantees — optimised for write throughput and row-level consistency. OLAP handles few large analytical queries (GROUP BY, aggregations, full-column scans over millions of rows) — optimised for read throughput. Mixing the two in a single system causes each to degrade the other. Storage selection starts with identifying which pattern dominates a given use case.
Q2. When is a document store preferable to a relational database?
A: When data has a genuinely variable or evolving schema (different entity types have different attribute sets), when the document is always retrieved as a whole unit (no cross-document joins needed), and when the flexibility of schema-on-write is more valuable than relational constraints. Not suitable when complex referential integrity or cross-document joins are required — those push join complexity to the application layer.
Q3. What is a data swamp, and what are the two most important preventive controls?
A: A data lake that has become unusable due to absent governance: no catalogue, no ownership, no naming conventions, no lineage, no schema management — files accumulate but nobody can trust or find them. The two most important preventive controls are: (1) implement a data catalogue and data ownership before the first dataset is ingested, and (2) enforce naming and partitioning conventions via code review or automated policy — not as optional guidelines.
Q4. What does an open table format (Apache Iceberg, Delta Lake) add to a data lake, and why does it matter for compliance?
A: Open table formats add ACID transaction semantics on top of object storage: atomic inserts,
UPDATE/DELETE/MERGEoperations, schema evolution tracking with backward compatibility, and time travel (query historical snapshots). For compliance, this enables GDPR right-to-erasure viaDELETE FROM <table> WHERE customer_id = X— which is otherwise impossible on raw Parquet files without rewriting entire partitions. It also enables upserts for incremental loads, which is the standard pattern for keeping warehouse-equivalent tables current.
Q5. Why should the data warehouse never become the system of record for operational data?
A: The warehouse is a derived analytical copy refreshed via ETL/ELT from OLTP systems. It is optimised for read-heavy analytical queries, not for transactional writes. Writing operational data directly to the warehouse bypasses ACID guarantees, creates circular dependency risks (what if the OLTP system and warehouse contradict each other?), and blurs accountability for data quality. The OLTP system is always the authoritative source; the warehouse is always a trusted-but-derivative reflection of it.
Quiz Alignment Note
Quizzes for sad4 will test: the five storage paradigms and their appropriate use cases given a described access pattern; the OLTP/OLAP distinction; the architectural relationship between operational databases, data lakes, and warehouses; governance concerns at the storage layer (ownership, lineage, access control, retention, deletion); the role of open table formats in enabling lakehouse capabilities and GDPR compliance; and storage selection given a scenario with defined NFRs.
Key Takeaways
- Five storage paradigms: relational OLTP, document store, data warehouse (OLAP), data lake, lakehouse. Each excels at a distinct access pattern. Mixing OLTP and OLAP workloads without separation creates performance and governance problems that grow with data volume.
- The OLTP → data warehouse pipeline is the standard architectural pattern for combining operational integrity with analytical accessibility. The warehouse is always downstream and always a derived copy.
- A data lake without governance is a data swamp. Implement catalogue, ownership, naming conventions, and schema management before you ingest data — not as a remediation project eighteen months later.
- The lakehouse (open table formats on object storage) is a legitimate architectural choice when you need a single storage layer serving both ML and BI workloads, and when ACID-capable operations (GDPR deletion, upserts) on large datasets are required. Evaluate it honestly against team skills and query-performance requirements.
- Data governance — ownership, lineage, access control, retention, deletion capability — is an architectural concern that must be designed into every storage layer from the beginning. Retrofitting GDPR deletion into a system that was not designed for it is one of the most expensive architectural mistakes a team can make.
- Storage decisions are durable and expensive to reverse. Apply the architecture checklist, evaluate paradigms against specific NFRs, and document choices in ADRs with consequences and risks.
Course Summary
This lesson completes the four-lesson foundation of the Solution Architecture & System Design course. You have built a connected toolkit:
- sad1: Architecture framing — the role, lifecycle, stakeholders, and ADR discipline.
- sad2: Requirements engineering — functional, non-functional, constraints, assumptions, and the RTM.
- sad3: Pattern selection — layered, monolith, microservices, event-driven — with principled trade-off analysis.
- sad4: Data layer decisions — OLTP, warehouse, lake, lakehouse — with governance woven through every choice.
These four capabilities combine in every real architecture engagement. The cloud architecture, security architecture, and integration design modules that follow will apply this foundation to specific technical domains — each building on the vocabulary, tools, and decision discipline introduced here.