- 01
How do INNER JOIN and LEFT JOIN differ?
Question codesqlSELECT customers.name, orders.id FROM customers INNER JOIN orders ON orders.customer_id = customers.id;INNER JOIN returns rows with matching records on both sides. LEFT JOIN keeps every row from the left side and uses null values where no right-side match exists.
Answer codesqlSELECT customers.name, orders.id FROM customers LEFT JOIN orders ON orders.customer_id = customers.id; -- Customers without an order remain, with a NULL order id. - 02
What does a database index improve and what does it cost?
An index can reduce the work needed to find, join, or order rows, depending on the query and index structure. It consumes storage and adds maintenance cost to writes, so indexes should follow observed access patterns.
- 03
What do ACID transaction properties describe?
Atomicity, consistency, isolation, and durability describe how a database protects a transaction and its committed result. Isolation level determines which concurrent effects are visible and involves correctness and performance tradeoffs.
- 04
Why normalize a relational schema?
Normalization reduces duplication and update anomalies by representing facts in appropriate relations. Selective denormalization can improve read patterns, but should preserve a clear source of truth.
- 05
How would you investigate a slow SQL query?
Inspect the actual query plan, row estimates, scans, joins, filters, sorting, data distribution, and lock waits. Improve the query, schema, or index based on measured behavior and verify it with representative data.
- 06
What causes database deadlocks?
A deadlock occurs when transactions wait on resources held by each other in a cycle. Keep transactions short, access resources in a consistent order, use suitable indexes, and safely retry the transaction selected as the victim.
Delivery & Infrastructure
SQL & Database Interview Questions and Answers
Review SQL and database interview questions on joins, indexes, transactions, normalization, query plans, locking, and reliable schema design.
Continue preparing
Related interview guides
Need delivery capability?
