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 → DDL Commands 2

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 2

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
What is SELECT FOR UPDATE SKIP LOCKED and what use case does it enable?
An extension to SELECT FOR UPDATE that skips (does not return or wait for) rows that are already locked by other transactions; enables non-blocking queue-like processing where multiple workers can each claim and process different rows without contention - perfect for job queues, task processing systems, and any pattern where multiple workers process items from a shared pool
click to copy

DBMS → Deadlock 1

What is deadlock probability as a function of transaction size and why do longer transactions cause more deadlocks?
Deadlock probability increases approximately as O(n^2) where n is the number of locks held per transaction: each transaction holding n locks has n potential conflicts with each other transaction; as transaction size (locks held) grows the probability of circular wait increases because each lock held is a potential blocker and each lock needed is a potential waiter
click to copy

DBMS → PL/SQL 3

What is native compilation (NATIVE) vs interpreted mode for PL/SQL and what are the performance trade-offs?
PL/SQL NATIVE: compiles PL/SQL code to native machine code via an external C compiler; eliminates interpreter overhead; best for CPU-intensive computations and complex algorithms. INTERPRETED: PL/SQL bytecode executed by the PL/SQL VM; faster compilation, simpler deployment; best for I/O-bound code (most DB code waits on SQL, not PL/SQL computation)
click to copy
What is PL/SQL profiling and what tools are available in Oracle for identifying PL/SQL bottlenecks?
PL/SQL profiling measures execution time and call counts for each line/procedure in PL/SQL code; Oracle provides DBMS_PROFILER (line-level timing), DBMS_HPROF (hierarchical profiler showing call trees and cumulative times), and PL/SQL Developer/SQL Developer GUI tools that visualize profiling data; essential for identifying slow procedures and optimization targets
click to copy
What is the PL/SQL function result cache (RESULT_CACHE) and what automatic invalidation mechanism does it use?
The PL/SQL RESULT_CACHE stores function results in the SGA (System Global Area) shared across all sessions; Oracle automatically invalidates cached results when any dependent database table or view is modified (DML commit), ensuring cache consistency without any manual intervention required
click to copy

DBMS → Introduction to DBMS 21

Which best describes the impedance mismatch problem?
Mismatch between data structures of programming languages and the relational model
click to copy
In three-schema architecture which layer provides logical independence?
Conceptual schema
click to copy
Which is NOT a property of ACID transactions?
Concurrency
click to copy
What is the primary difference between a data warehouse and a traditional DBMS?
Data warehouses are optimized for analytical read-heavy workloads; DBMS for transactional write-heavy workloads
click to copy
Which catalog component stores metadata about tables, views, and indexes?
System catalog / Metadata repository
click to copy
Data abstraction in DBMS provides which primary advantage?
Shielding users from physical storage complexity while maintaining logical clarity
click to copy
Which correctly describes the difference between DDL and DML?
DDL defines schema structure; DML retrieves and manipulates data
click to copy
Physical data independence in DBMS means:
Ability to change internal/physical schema without changing the conceptual schema
click to copy
Who is responsible for defining the conceptual schema?
Database Administrator (DBA)
click to copy
A view in DBMS primarily provides which level of abstraction?
View/External level
click to copy
Which is a disadvantage of file-based systems compared to DBMS?
Data redundancy and inconsistency
click to copy
The closed world assumption in DBMS means:
Any data not stored is assumed to be false/non-existent
click to copy
Which best defines data integrity in DBMS?
Ensuring accuracy, consistency, and validity of data throughout its lifecycle
click to copy
In DBMS terminology a schema is:
The overall design or logical structure of the database
click to copy
What is the instance of a database?
The actual data stored in the database at a particular moment in time
click to copy
Which component converts high-level queries into efficient low-level operations?
Query Optimizer
click to copy
What is data independence fundamentally protecting against?
The ripple effect of changes in one schema level propagating to another
click to copy
Which is a characteristic of an active database?
It can automatically trigger actions via triggers in response to database events
click to copy
In DBMS terminology a relation is equivalent to:
A table
click to copy
Which statement about NULL values is most accurate?
NULL represents an unknown, missing, or inapplicable value
click to copy
The ANSI/SPARC three-schema architecture was proposed primarily to achieve:
Data independence between different levels of database abstraction
click to copy