Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

DBMS → Database Architecture 3

What is the active-active database cluster and what challenges does it present?
A cluster where multiple nodes simultaneously accept read and write operations; challenges include write-write conflicts (two nodes update same row simultaneously), conflict resolution strategies, increased network overhead for synchronization, and consistency vs availability trade-offs
click to copy
What is HTAP (Hybrid Transactional/Analytical Processing) database architecture?
An architecture that combines OLTP and OLAP workloads in the same database system, eliminating the need for separate data warehouse ETL pipelines; achieves this through in-memory row store for OLTP plus columnar store for OLAP, or real-time replication from row store to column store
click to copy
What is database sharding and what is the difference between range sharding and hash sharding?
Sharding horizontally distributes data across multiple database servers; range sharding: assigns rows based on key value ranges enabling efficient range queries but risking hot spots; hash sharding: distributes rows using hash(key) mod num_shards providing even distribution but preventing efficient range scans
click to copy

DBMS → Data Models 7

What is the object-relational impedance mismatch and how do ORMs address it?
The conceptual gap between object-oriented programming (inheritance, associations, identity, encapsulation) and relational databases (tables, foreign keys, joins, set-based operations); ORMs address this by providing mapping configurations that translate between object graphs and table rows
click to copy
What is the document embedding vs referencing decision in document data models?
In document databases: embedding stores related data as nested sub-documents within a parent document (denormalized, one read, no joins but large documents); referencing stores related data in separate collections with explicit references (normalized, requires multiple reads but smaller documents and shared data); the choice depends on access patterns and update frequency
click to copy
What is the columnar data model and how does Apache Parquet implement it?
A storage format where data for each column is stored contiguously rather than row-by-row; Apache Parquet implements this with row groups (horizontal partitions), column chunks (vertical partitions within a row group), nested encoding (Dremel levels for nested schemas), and column statistics enabling predicate pushdown
click to copy
What is the time-series data model and what specific optimizations make it different from a general-purpose relational model?
A data model optimized for append-only time-stamped measurements with automatic time-based partitioning, compressed columnar storage (delta encoding compresses well), downsampling of old data, and specialized time functions such as interpolation, moving averages, and gap filling
click to copy
What is the difference between schema-on-read and schema-on-write approaches in data modeling?
Schema-on-write (traditional RDBMS): schema is defined and enforced before data is written; data must conform to schema at write time (strict, consistent but less flexible). Schema-on-read (Hadoop/data lake): raw data is stored without enforcing schema; schema is applied when data is read (flexible, accepts any data format)
click to copy
What is the outbox pattern in data modeling for distributed systems?
A pattern that ensures atomicity between database writes and message/event publishing: write the event to an outbox table in the same DB transaction as the business data, then have a separate process reliably publish from the outbox, ensuring events are never lost even if the broker is temporarily unavailable
click to copy
What is the data vault modeling approach and when is it preferred over star schema?
A hybrid data modeling methodology for enterprise data warehouses that separates hubs (business keys), links (relationships between hubs), and satellites (descriptive attributes with history); preferred when requirements change frequently, full historical tracking is needed, or multiple source systems need to be integrated incrementally
click to copy

DBMS → ER Model 5

What is the difference between conceptual, logical, and physical ER models?
Conceptual ER: high-level diagram with entities and relationships only (no attributes or keys), technology-agnostic, used for stakeholder communication. Logical ER: adds attributes, primary/foreign keys, cardinality, normalization, still DBMS-agnostic. Physical ER: DBMS-specific implementation (actual table names, data types, indexes, constraints, partitioning)
click to copy
What is cardinality notation in ER diagrams and what are the main notational systems used?
Symbols in ER diagrams that specify how many instances of one entity can be associated with instances of another entity; main systems: Chen notation (1, N, M near relationship diamonds), Crow Foot notation (symbols on relationship lines used in most modern tools), UML class diagram notation (1, 0..1, *, 1..*), and IDEF1X notation
click to copy
What is entity subtyping and what are the three common implementation strategies in relational databases?
Entity subtyping (specialization/generalization) maps a supertype-subtype hierarchy to relational tables using: Single Table Inheritance (one table, nulls for subtype-specific columns), Table Per Type (supertype table plus subtype tables with FK to supertype), or Table Per Concrete Type (one table per concrete subtype with no joins but redundant common columns)
click to copy
What is the surrogate key vs natural key debate in ER/relational design?
Surrogate key (system-generated integer/UUID): stable (never changes even if business data changes), simple (single column joins), private (no business meaning exposed); Natural key (business identifier like SSN, ISBN): meaningful, already unique, no extra column needed but may change, may be complex, may expose sensitive data. Best practice: surrogate PK with unique constraint on natural key
click to copy
What is the concept of ontological commitment in ER modeling and how does it affect schema design?
The set of assumptions made about the nature and categories of entities in the domain; in ER design this means deciding what constitutes an entity vs an attribute vs a relationship - different ontological choices lead to fundamentally different schemas that are logically equivalent but have different query performance and flexibility trade-offs
click to copy

DBMS → Relational Model 4

What are Codds 12 rules and what is Rule 0 (the foundation rule)?
Codds 12 rules define what constitutes a truly relational DBMS; Rule 0 (Foundation Rule): a system that claims to be a relational database management system must be able to manage databases entirely through its relational capabilities - no special non-relational mechanisms should be required
click to copy
What is domain calculus in relational databases and how does it differ from tuple calculus?
Both are non-procedural query languages equivalent in power to relational algebra. Tuple relational calculus: variables range over tuples (rows). Domain relational calculus: variables range over individual attribute values (domains). Both are the theoretical foundation for SQL
click to copy
What is relational completeness and what does it mean for a query language?
A query language is relationally complete if it is at least as expressive as relational algebra; i.e., it can express any query that relational algebra can express. SQL is relationally complete (and more, with aggregate functions, recursion, etc.). A language that cannot express certain relational algebra operations is not relationally complete
click to copy
What is query containment in relational databases and why is it important for query optimization?
Query Q1 is contained in Q2 (Q1 <= Q2) if for every database instance D the result of Q1 on D is a subset of the result of Q2 on D; important for: query optimization (replace Q1 with cheaper equivalent Q2), semantic caching (if cached result of Q2 contains all results of Q1 use cache), and query rewriting using materialized views
click to copy

DBMS → Normalization 3

What is over-normalization and how can it harm database performance?
Normalizing beyond what is practically necessary, resulting in too many tables that require expensive JOIN operations for every query; symptoms include 5+ table joins for common queries, poor OLTP performance due to join overhead, complex application code to reconstruct objects, and negligible storage savings that do not justify the performance cost
click to copy
What is the difference between lossless join and dependency-preserving decomposition and why might you choose one over the other?
Lossless join: joining decomposed relations returns exactly the original relation (no spurious tuples) - mandatory for correctness. Dependency-preserving: all original FDs can be verified in decomposed relations without joins - desirable but not always achievable with BCNF. 3NF always achieves both but BCNF may sacrifice dependency preservation for stronger redundancy elimination
click to copy
What is normalization by synthesis vs normalization by decomposition?
Synthesis (3NF synthesis algorithm): constructs normalized relations from scratch using minimal cover of FDs; bottom-up approach that creates one relation per FD in canonical cover and ensures lossless plus dependency-preserving result. Decomposition (BCNF decomposition): starts with one large unnormalized relation and repeatedly splits it by finding violating FDs; top-down approach
click to copy

DBMS → SQL Basics 3

What is the SQL standard window frame specification and how does ROWS differ from RANGE?
Window frame defines the subset of rows within a partition considered for each calculation. ROWS: physical row offset (always a fixed number of rows). RANGE: logical value range (all rows within a specified value distance of current row's ORDER BY value, which may include many rows if duplicates exist)
click to copy
What is SQL grouping sets feature and how does it extend GROUP BY?
GROUPING SETS allows computing multiple GROUP BY aggregations in a single query pass; ROLLUP generates subtotals and grand total for a hierarchy; CUBE generates all possible combinations of group-by columns; more efficient than multiple UNION ALL queries because the data is scanned only once
click to copy
What is a lateral join or APPLY operator in SQL and what makes it different from a regular join?
LATERAL (PostgreSQL/SQL standard) or CROSS APPLY/OUTER APPLY (SQL Server): allows a subquery or table-valued function in the FROM clause to reference columns from preceding tables in the same FROM clause; a regular derived table subquery cannot reference outer columns - LATERAL enables correlated subqueries in the FROM clause
click to copy

DBMS → DDL Commands 3

What is a deferred constraint and when is it used in DDL?
A constraint declared with DEFERRABLE INITIALLY DEFERRED is checked at COMMIT time rather than after each statement; used for circular foreign key references, bulk loading where intermediate states temporarily violate constraints, and complex multi-step operations where the final committed state is valid
click to copy
What is the difference between DROP TABLE and DROP TABLE IF EXISTS?
DROP TABLE fails with an error if the specified table does not exist; DROP TABLE IF EXISTS silently succeeds (no error) if the table does not exist - useful in scripts that should be idempotent (safe to run multiple times) like migration scripts or setup scripts that may run on databases where the table may or may not already exist
click to copy
What is a computed or generated column and what are the restrictions on expressions that can be used?
A column whose value is automatically derived from an expression involving other columns in the same row; restrictions include: expression must be deterministic (no RAND() or NOW()), cannot reference other generated columns, cannot reference other tables, STORED generated columns cannot be updated directly by users
click to copy

DBMS → DML Commands 2

What is the INSERT IGNORE vs INSERT OR REPLACE behavior on a unique key constraint violation in MySQL?
INSERT IGNORE: on unique key violation, silently skips the insert and keeps the original row unchanged (no error); INSERT OR REPLACE (REPLACE INTO): on unique key violation, deletes the conflicting row then inserts the new one (old row is gone, new auto-increment value generated, ON DELETE triggers fire)
click to copy
What is row locking vs table locking in the context of DML operations and how does it affect concurrency?
Row-level locking: only the rows being modified are locked allowing other transactions to modify different rows concurrently (high concurrency, higher overhead). Table-level locking: the entire table is locked during DML (simple, low overhead, but blocks all other DML on the table); appropriate for bulk operations
click to copy

DBMS → Joins 3

What is the driving table concept in nested loop join execution and how does the optimizer choose it?
In a nested loop join the driving table (outer loop) is the table whose rows are iterated one by one with the inner table looked up for each outer row; the optimizer chooses the smaller or more filtered table as the driving table to minimize iterations; an index on the inner table's join column is critical
click to copy
What is predicate pushdown through a join and why is it important for query performance?
Moving filter conditions (WHERE predicates) to be applied as early as possible in the execution plan - ideally directly on the base table scan before the join - so that fewer rows participate in the join operation; this is one of the most impactful query optimizer transformations and can reduce join input size by orders of magnitude
click to copy
What is a hash join spill and what happens when the build-side hash table does not fit in memory?
When the build-side relation is too large to fit in the allocated hash join memory, the DBMS performs a grace hash join: partitions both relations to disk using the hash function (ensuring matching rows land in same partition files), then processes each partition pair independently in memory; this increases I/O but prevents out-of-memory errors
click to copy

DBMS → Views 2

What is view dependency tracking and why is it critical for database change management?
The process of maintaining records of which views depend on which base tables (and which views depend on other views), enabling DBAs to identify the impact of schema changes before making them, determine the correct order to drop/recreate objects, and automatically invalidate dependent objects when base schemas change
click to copy
What is the performance impact of deeply nested views (view on view on view) in a DBMS?
Deep view nesting adds query parsing and optimization overhead; the query optimizer must recursively expand all view definitions before planning; deep nesting can prevent some optimizer transformations (predicate pushdown, join reordering) if intermediate view definitions use features that block merging such as aggregates, DISTINCT, or LIMIT
click to copy

DBMS → Indexes 2

What is index selectivity estimation and why do stale statistics cause poor query plans?
The query optimizer estimates how many rows an index access will return using column statistics (histogram, distinct value count, null fraction); stale statistics cause the optimizer to generate suboptimal plans such as choosing a full table scan when a highly selective index exists or choosing an index scan when most rows match and a full scan would be faster
click to copy
What is the difference between index range scan and full index scan in execution plans?
Index range scan: uses the B-tree to navigate to the start of a range and reads sequentially until the range end; efficient for selective range conditions. Full index scan: reads all leaf pages of the index from start to end; used when ORDER BY matches index, covering index answers query without heap access, or for small tables
click to copy

DBMS → Transactions 2

What is a compensation transaction in distributed transaction management and when is it used?
A compensation transaction is a semantically inverse operation that undoes the effects of a previously committed transaction when a later step in a distributed saga or workflow fails; unlike physical undo (only possible for uncommitted transactions), compensation is a new positive transaction that reverses the business effect such as issuing a refund to compensate for a completed charge
click to copy
What is the lost update problem and which isolation level prevents it?
The lost update problem: T1 reads value X=100, T2 reads value X=100, T1 writes X+=50 (X=150), T2 writes X+=30 (X=130 based on its stale read) - T1 update is lost. Prevented by: REPEATABLE READ (read locks prevent T2 from reading until T1 commits), SERIALIZABLE, or optimistic locking (T2 update fails because X changed since T2 read it)
click to copy

DBMS → Concurrency Control 1

What is lock contention and what strategies reduce it in high-throughput OLTP systems?
Lock contention occurs when multiple transactions compete for the same locks causing waiting and reducing throughput; strategies to reduce it: shorter transactions, access patterns that minimize lock scope, optimistic locking, MVCC (readers never block writers), partitioning hot data across shards, and batch versus row-level updates
click to copy