Quick revision
The short answer
I would separate the two workloads. The OLTP schema stays normalized and serves operational screens; reporting moves to a warehouse or lakehouse fed by change data capture (for example Debezium reading the database log), where star schemas and wide tables are built cheaply without touching write latency. Near-real-time operational needs use read replicas or materialized views with stated freshness, the report-only triggers and columns are removed, and data contracts on the CDC stream stop schema changes from silently breaking reports.
What to remember
In this answer, we saw why report-only columns and triggers in an OLTP database slow writes and hide coupling, and designed a split: a normalized OLTP schema publishing its changes through CDC, a landing zone and reporting models such as star schemas downstream, read replicas or materialized views with explicit freshness targets for near-real-time needs, and data contracts on the stream. We removed the triggers by rebuilding each report first, comparing results, and only then dropping them.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would separate the two workloads. The OLTP schema stays normalized and serves operational screens; reporting moves to a warehouse or lakehouse fed by change data capture (for example Debezium reading the database log), where star schemas and wide tables are built cheaply without touching write latency. Near-real-time operational needs use read replicas or materialized views with stated freshness, the report-only triggers and columns are removed, and data contracts on the CDC stream stop schema changes from silently breaking reports.
Why this question is asked
Every successful product reaches the point where the database that runs the business is also asked to explain the business, and the two jobs pull the schema in opposite directions. Operational screens want small, fast, consistent writes; reports want wide, precomputed, historical reads. Teams that serve both from one schema add columns and triggers until every insert does reporting work. Interviewers ask this to see whether we can design the split and migrate to it. In this answer, we will look at why the current approach hurts, design the target architecture layer by layer, explain how CDC works, deal with freshness needs, and plan how to remove the triggers safely.
1Why Report Columns in the OLTP Database Hurt
OLTP stands for online transaction processing: many small reads and writes, each touching a few rows, that must be fast and correct. Reporting, sometimes called OLAP (online analytical processing), runs few but large queries that scan and aggregate millions of rows. The two have different ideal shapes. OLTP wants normalized tables so each write changes one place. Reporting wants denormalized tables so a query does not join ten tables.
When reporting needs are met inside the OLTP schema, each new report adds a column such as orders.region_name or customers.lifetime_value, plus a trigger to keep it updated. Every order insert now fires several triggers that read other tables and update summary rows, so write latency grows and summary rows become hot spots under lock contention. The coupling is hidden too: a developer changing the orders table cannot see that four reports depend on a trigger. And heavy report queries still run on the primary, competing with checkout for CPU and cache.
2The Target Architecture
The idea is that the OLTP database publishes its changes and stops doing reporting work. Reporting models are built downstream, where denormalization is cheap because nothing transactional depends on it.
- OLTP databaseNormalized schema, constraints, operational screens
- Change data captureDebezium reads the WAL, publishes row changes to Kafka
- Data contractsVersioned schemas for each change topic
- Raw landing zoneChanges stored as received, replayable
- Reporting modelsStar schemas and wide tables built by jobs (for example dbt)
- BI and reportsDashboards, finance exports, ad hoc analysis
6 layers, from the top down. Step through them one at a time.
The OLTP database only writes its log; everything below can be rebuilt by replaying changes.
A star schema is a reporting layout with one central fact table (for example one row per order line, with amounts) surrounded by dimension tables (customer, product, date, region) that describe the facts. Reports join the fact table to a few dimensions instead of walking the whole normalized model, and the warehouse is built for exactly those scans.
3How Change Data Capture Feeds the Warehouse
Change data capture, CDC, means reading every committed change from the database's own log rather than querying tables. PostgreSQL writes all changes to its write-ahead log (WAL) before applying them, and logical decoding turns that log into row-level change events. Debezium is a common open-source connector that does this and publishes events to Kafka.
The key property is that capture adds almost no work to the write path: the database writes the WAL anyway, and the connector reads it afterwards. Unlike dual writes from application code, CDC cannot miss a change made by a script or another service, because every committed change is in the log. There is a catch: a replication slot keeps WAL on disk until the connector has read it, so a stopped connector can fill the disk. Slot lag must be monitored and alerted.
4Serving Near-Real-Time Operational Needs
Not every report can wait for a warehouse pipeline. A warehouse supervisor wants today's picked orders updated within a minute, and that is operational, not analytical. For these we use tools closer to the OLTP data, with an explicit freshness target agreed with the users.
A read replica is a copy of the database kept in sync from the WAL, usually less than a second behind, where heavy read queries can run without loading the primary. A materialized view stores a query's result and is refreshed on a schedule, for example every five minutes with REFRESH MATERIALIZED VIEW CONCURRENTLY so readers are not blocked. The rule is that each such need is written down with its freshness target (under 1 second, 5 minutes, next morning) so the team picks the cheapest layer that meets it rather than reaching for a trigger.
5Removing the Triggers Safely
We cannot drop triggers that reports depend on before replacements exist. So we inventory every report-only column and trigger, find which report reads it, rebuild that report on the new reporting model, run both side by side and compare numbers for a few weeks, and only then drop the trigger and column.
Each removal is a measurable win: we can track insert latency on orders before and after. Finally we add a design review rule that new report needs go to the reporting layer by default, so the pattern does not grow back.
6Data Contracts on the CDC Stream
CDC has one danger of its own: it exposes the OLTP schema to downstream consumers. If a developer renames orders.status to orders.state, the change stream changes shape and a finance report breaks overnight. A data contract is an agreed, versioned schema for each published stream, with a registry (such as a schema registry for Avro or JSON Schema) that rejects incompatible changes, and an owner on each side.
In practice we publish curated streams rather than every raw column, or we use the outbox pattern for domain events, so the internal schema can evolve while the published contract stays stable. Schema changes then go through the same review as API changes.
7Follow-up questions
Why not just point reports at a read replica and stop there?
A replica removes the load from the primary, which is a good first step, but it has the same normalized schema, so reports still do the big joins and the denormalized columns still seem attractive. It also cannot keep history that the OLTP database deletes or overwrites. A replica is the right tool for near-real-time operational reads, while a warehouse fed by CDC is the right tool for reporting models and history.
What freshness can CDC into a warehouse achieve?
The capture itself is usually seconds behind. The end-to-end delay depends on how often the reporting models are rebuilt, which can be every few minutes for incremental models or nightly for heavy ones. We agree a target per report rather than promising one number.
How do you handle deletes in the CDC stream?
Debezium emits a delete event and, by default, a tombstone for Kafka compaction. The landing zone keeps the delete as a row with an operation type, so models can either remove the row or keep it with a deleted flag, depending on whether the report needs history.
8Conclusion
In this answer, we saw why report-only columns and triggers in an OLTP database slow writes and hide coupling, and designed a split: a normalized OLTP schema publishing its changes through CDC, a landing zone and reporting models such as star schemas downstream, read replicas or materialized views with explicit freshness targets for near-real-time needs, and data contracts on the stream. We removed the triggers by rebuilding each report first, comparing results, and only then dropping them.
Open with
I would separate the two workloads instead of letting reporting keep shaping the OLTP schema. The operational database stays normalized and serves the screens. Every report column plus trigger adds write latency, creates hot summary rows and hides coupling, and heavy report queries still compete with checkout on the primary.
Then, if they want more
For reporting, I would set up change data capture, for example Debezium reading PostgreSQL's write-ahead log through logical decoding and publishing row changes to Kafka. That adds almost nothing to the write path and cannot miss changes made by scripts, unlike dual writes.
The changes land in a warehouse or lakehouse, and jobs build star schemas and wide tables there, where denormalization is cheap and nothing transactional depends on it. For near-real-time operational needs, like a supervisor's dashboard, I would use a read replica or a materialized view refreshed every few minutes, with the freshness target written down.
Then I would remove the report triggers one by one: rebuild the report downstream, run both and compare numbers, and only then drop the trigger and column, measuring insert latency as we go.
Finally, CDC exposes the internal schema, so I would put data contracts on the published streams with a schema registry and owners, so a column rename cannot silently break finance reports. I would also monitor replication slot lag so a stuck connector cannot fill the disk.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Your product needs operational screens over the normalized OLTP schema and also heavy...": https://scrivio-interview-library.netlify.app/databases/data-modeling/4d744f9ffe/