More in Databases & Architecture — page 5
How do you keep consistency without multi-document transactions?
WHAT IT TESTS: maintaining integrity across services without distributed ACID. OUTLINE: a Saga runs a sequence of local transactions, each with a compensating action to undo on failure, coordinated via choreography or orchestration.
Why fit Cassandra to a high-read, high-write workload?
WHAT IT TESTS: mapping Cassandra's masterless architecture to throughput needs. OUTLINE: consistent-hash partitioning spreads load, replication and no single master give availability, log-structured writes are fast, tunable consistency balances per query.
What are eventual consistency and the BASE model?
WHAT IT TESTS: trading consistency for availability per feature. OUTLINE: eventual consistency means replicas converge given no new writes; BASE is Basically Available, Soft state, Eventually consistent.
Embed or reference likes in a document database?
WHAT IT TESTS: document modeling driven by access patterns and growth. OUTLINE: embedding is fast for small bounded lists but unbounded likes hit document size limits; referencing scales for high-cardinality, write-heavy likes.
What is the CAP theorem?
WHAT IT TESTS: grasp of fundamental distributed-systems limits. OUTLINE: Consistency, Availability, Partition tolerance; during a network partition you must choose between staying consistent or staying available.
How do you choose between relational and NoSQL databases?
WHAT IT TESTS: ability to match a data model to requirements. OUTLINE: relational gives schema, joins, and ACID for structured related data; document gives flexible schema and horizontal scale for varied or denormalized data.
How does a hash join handle memory overflow?
WHAT IT TESTS: understanding of query execution under memory pressure. OUTLINE: the build table is partitioned by hash and spilled to disk, then probe rows are partitioned the same way, and pairs are joined per partition.
Sorting data larger than memory
WHAT IT TESTS: external sorting. OUTLINE: external merge sort reads memory-sized chunks, sorts each in RAM and writes them as sorted runs to disk, then merges many runs together in passes until one sorted output remains.
Hash join versus sort-merge join
WHAT IT TESTS: choosing between two equi-join strategies. OUTLINE: hash join builds and probes a hash table, great for unsorted equality joins with enough memory; sort-merge sorts both inputs then merges, winning when inputs are already sorted or output must…
Joining a large table with a small one
WHAT IT TESTS: matching join algorithm to data size. OUTLINE: with a tiny table the optimizer often picks a hash join, building a hash table on the small side in memory, then probing it once per row of the large table in a single pass.
Why developers read query plans
WHAT IT TESTS: basic EXPLAIN literacy. OUTLINE: the plan shows the operators the optimizer chose to run a query; developers read it to find why a query is slow; a common thing to look for is a full table scan where an index was expected.
Stages of executing a SELECT query
WHAT IT TESTS: the query pipeline. OUTLINE: parse the SQL into a tree, bind and validate against the catalog, optimize into a physical plan, then execute the plan operators fetching data and returning rows.
Using page LSN to decide redo
WHAT IT TESTS: idempotent redo via LSNs. OUTLINE: each page stores the LSN of its last applied change; during redo the engine reapplies a log record only if its LSN exceeds the page's LSN, meaning the change is not yet reflected on disk.
Row-oriented versus columnar storage
WHAT IT TESTS: storage layout for OLTP versus OLAP. OUTLINE: row stores keep whole rows together, ideal for point reads and writes; columnar stores keep each column contiguous, enabling reading only needed columns and strong compression, ideal for scans and…
The three phases of ARIES recovery
WHAT IT TESTS: crash-recovery internals. OUTLINE: Analysis rebuilds dirty-page and transaction tables from the last checkpoint, Redo replays all logged changes to restore state, Undo rolls back losers; Redo is idempotent via per-page LSN comparison so…
B+ Tree range queries across pages
WHAT IT TESTS: how B+ Trees map to disk. OUTLINE: internal nodes are pages of keys guiding the search, all data sits in linked leaf pages; a range query descends to the start key then follows the leaf chain sequentially until the upper bound.
Lifecycle of a single row update
WHAT IT TESTS: end-to-end write path. OUTLINE: buffer manager faults the page in, the row is modified in memory marking the page dirty, a WAL record is written, and commit fsyncs the log while the dirty page is flushed later by a checkpoint.
Heap file versus clustered index
WHAT IT TESTS: physical table organization. OUTLINE: a heap stores rows unordered with cheap inserts but no inherent ordering; a clustered or index-organized table stores rows in primary-key order, giving fast key range reads but costlier inserts and page…
Database checkpoints with WAL
WHAT IT TESTS: balancing recovery time and runtime I/O. OUTLINE: a checkpoint flushes dirty pages and records a known-good point so recovery can start later in the log; frequent checkpoints shorten recovery but add I/O spikes, infrequent ones lengthen…
Purpose of the Write-Ahead Log
WHAT IT TESTS: durability mechanics. OUTLINE: WAL records changes sequentially and is flushed to disk before commit; the rule is log first, then data pages may lag; on crash the database replays the log to recover committed work.