Question presented to candidate: "People talk about OLTP databases and OLAP databases as if they were different things. What is the difference, why can't one database just do both well, and how would a typical company set them up?"
What a strong answer should cover:
- OLTP (online transaction processing): many small, short read/write transactions touching a few rows by key β placing an order, updating stock; needs low latency, high concurrency, ACID, a normalised schema and B-tree indexes
- OLAP (online analytical processing): fewer, large read-mostly queries scanning and aggregating millions of rows β revenue by month and region; needs throughput, a denormalised star schema, and usually columnar storage with compression
- Why the storage layout differs: row stores read whole rows (good for "fetch order 7"), column stores read only the columns a query uses (good for "sum one column over a billion rows")
- How they connect: data is copied from OLTP systems into a warehouse by ETL/ELT or change data capture, so analytics do not slow down user-facing transactions
- Examples of each kind (PostgreSQL, MySQL, SQL Server for OLTP; Snowflake, BigQuery, Redshift, ClickHouse for OLAP) and the HTAP middle ground
Code / implementation expected: Optional β an OLTP transaction and point lookup next to an OLAP aggregation, or a small fact/dimension example.
Schema used by the examples: