InterviewSkill

DBMS Interview Questions

Database fundamentals for transactions, indexing, modeling, and consistency discussions.

9 questions
DBMS

What are ACID properties?medium

Type
conceptual
Topic
acid-properties
Frequency
common
Tags
acid, properties
Answer

ACID means Atomicity, Consistency, Isolation, and Durability.

Explanation

ACID makes transactions reliable by ensuring all-or-nothing execution, valid state transitions, safe concurrency, and committed data persistence.

Follow-upWhich ACID property is affected by isolation levels?

What is normalization?medium

Type
conceptual
Topic
normalization
Frequency
common
Tags
normalization
Answer

Normalization organizes data to reduce redundancy and improve integrity.

Explanation

It splits data into related tables and uses keys to avoid repeated facts, update anomalies, and inconsistent records.

Follow-upWhy might a system intentionally denormalize data?

What is an index?hard

Type
conceptual
Topic
index
Frequency
common
Tags
index
Answer

An index helps a database find rows faster.

Explanation

Indexes reduce read cost but add storage and write overhead because index structures must be maintained when data changes.

Follow-upWhy can too many indexes hurt performance?

What is a transaction isolation level?medium

Type
conceptual
Topic
transaction-isolation-level
Frequency
common
Tags
transaction, isolation, level
Answer

It controls how much concurrent transactions can see or affect each other.

Explanation

Isolation levels trade consistency for performance and can prevent anomalies such as dirty reads, non-repeatable reads, and phantom reads.

Follow-upWhat is the difference between repeatable read and serializable?

What is a primary key?medium

Type
conceptual
Topic
primary-key
Frequency
common
Tags
primary, key
Answer

A primary key uniquely identifies each row in a table.

Explanation

It should be unique and non-null, and it provides a stable reference for relationships through foreign keys.

Follow-upHow is a primary key different from a unique key?

Why are B-tree indexes common in databases?medium

Type
conceptual
Topic
btree-index
Frequency
common
Tags
indexing, btree, query-performance
Answer

They keep keys sorted, making equality lookups, range scans, and ordered reads efficient.

Explanation

B-trees have balanced height, so searches require relatively few page reads. They are useful for WHERE filters, joins, ORDER BY, and range predicates.

Follow-upWhen might an index not be used by the query planner?

What is a database deadlock?hard

Type
conceptual
Topic
deadlock
Frequency
common
Tags
transactions, locking, deadlock
Answer

A deadlock happens when transactions wait on each other in a cycle, so none can continue.

Explanation

Databases usually detect deadlocks and abort one transaction. Consistent lock ordering, shorter transactions, and retry logic reduce deadlock impact.

Follow-upHow should an application handle a deadlock error?

How do you use an execution plan to debug a slow query?hard

Type
scenario
Topic
explain-plan
Frequency
common
Tags
query-plan, performance, indexes
Answer

Check scan types, join order, estimated versus actual rows, sort steps, and index usage.

Explanation

Execution plans show how the database intends to run a query. Large sequential scans, bad estimates, missing indexes, or expensive sorts often explain latency.

Follow-upWhy can stale statistics lead to a poor query plan?

SCD Type 1 vs Type 2 — how do you apply them in ETL?medium

Type
scenario
Topic
scd-type-1-vs-type-2-how-did-you-apply-them-in-databricks
Frequency
common
Tags
dbms, scd, type, how, did
Answer

SCD Type 1 overwrites the old value (no history). SCD Type 2 adds a new row with effective/expiry dates (full history).

Explanation

SCD Type 1 overwrites the old value (no history). SCD Type 2 adds a new row with effective/expiry dates (full history). Dimension tables like product catalog used Type 2 to track price changes over time; operational tables used Type 1. Implemented via merge/upsert logic in PySpark processing CDC data from Amazon DMS.

Follow-upWhat tradeoffs did you consider in that implementation?