Interview Q&A · 42 questions · 10 answered publicly
SQL & Databases Interview Questions
Ordered by how often they're asked. Sign in free to see every answer, rate your confidence and run timed mock interviews.
-
Most asked SQL interview: explain INNER JOIN.
Summary
Returns matching rows from both tables on join predicate.
Longer Answer
Returns matching rows from both tables on join predicate. SQL topic: INNER JOIN.
Key Points
- Returns matching rows from both tables on join predicate
- SQL topic: INNER JOIN
- Relevant areas: SQL, Query
- Use the answer to connect the concept back to a realistic production or interview scenario for 'SQL interview: explain INNER JOIN.'
Comparison / Tradeoffs
Aspect Notes Core idea Returns matching rows from both tables on join predicate. Practical tradeoff SQL topic: INNER JOIN. -
Most asked SQL interview: explain LEFT JOIN.
Summary
All left rows plus matches; NULLs when no match.
Longer Answer
All left rows plus matches; NULLs when no match. SQL topic: LEFT JOIN.
Key Points
- All left rows plus matches; NULLs when no match
- SQL topic: LEFT JOIN
- Relevant areas: SQL, Query
- Use the answer to connect the concept back to a realistic production or interview scenario for 'SQL interview: explain LEFT JOIN.'
Comparison / Tradeoffs
Aspect Notes Core idea All left rows plus matches; NULLs when no match. Practical tradeoff SQL topic: LEFT JOIN. -
Most asked SQL interview: explain GROUP BY.
Summary
Aggregate per group; SELECT non-aggregates must be grouped.
Longer Answer
Aggregate per group; SELECT non-aggregates must be grouped. SQL topic: GROUP BY.
Key Points
- Aggregate per group; SELECT non-aggregates must be grouped
- SQL topic: GROUP BY
- Relevant areas: SQL, Query
- Use the answer to connect the concept back to a realistic production or interview scenario for 'SQL interview: explain GROUP BY.'
Comparison / Tradeoffs
Aspect Notes Core idea Aggregate per group; SELECT non-aggregates must be grouped. Practical tradeoff SQL topic: GROUP BY. -
Most asked SQL interview: explain HAVING.
Summary
Filter groups after aggregation.
Longer Answer
Filter groups after aggregation. SQL topic: HAVING.
Key Points
- Filter groups after aggregation
- SQL topic: HAVING
- Relevant areas: SQL, Query
- Use the answer to connect the concept back to a realistic production or interview scenario for 'SQL interview: explain HAVING.'
Comparison / Tradeoffs
Aspect Notes Core idea Filter groups after aggregation. Practical tradeoff SQL topic: HAVING. -
Most asked SQL interview: explain window functions.
Summary
ROW_NUMBER/RANK/SUM OVER partitions without collapsing rows.
Longer Answer
ROW_NUMBER/RANK/SUM OVER partitions without collapsing rows. SQL topic: window functions.
Key Points
- ROW_NUMBER/RANK/SUM OVER partitions without collapsing rows
- SQL topic: window functions
- Relevant areas: SQL, Query
- Use the answer to connect the concept back to a realistic production or interview scenario for 'SQL interview: explain window functions.'
Comparison / Tradeoffs
Aspect Notes Core idea ROW_NUMBER/RANK/SUM OVER partitions without collapsing rows. Practical tradeoff SQL topic: window functions. -
Most asked SQL interview: explain ACID.
Summary
Atomicity, Consistency, Isolation, Durability.
Longer Answer
Atomicity, Consistency, Isolation, Durability. SQL topic: ACID.
Key Points
- Atomicity, Consistency, Isolation, Durability
- SQL topic: ACID
- Relevant areas: SQL, Query
- Use the answer to connect the concept back to a realistic production or interview scenario for 'SQL interview: explain ACID.'
Comparison / Tradeoffs
Aspect Notes Core idea Atomicity, Consistency, Isolation, Durability. Practical tradeoff SQL topic: ACID. -
Most asked SQL interview: explain isolation levels.
Summary
Read uncommitted to serializable; trade consistency vs concurrency.
Longer Answer
Read uncommitted to serializable; trade consistency vs concurrency. SQL topic: isolation levels.
Key Points
- Read uncommitted to serializable; trade consistency vs concurrency
- SQL topic: isolation levels
- Relevant areas: SQL, Query
- Use the answer to connect the concept back to a realistic production or interview scenario for 'SQL interview: explain isolation levels.'
Comparison / Tradeoffs
Aspect Notes Core idea Read uncommitted to serializable; trade consistency vs concurrency. Practical tradeoff Read uncommitted to serializable; trade consistency vs concurrency. -
Most asked Data modeling: normalization 1NF/2NF/3NF?
Summary
Reduce redundancy and update anomalies; 3NF common target.
Longer Answer
Reduce redundancy and update anomalies; 3NF common target. Modeling: normalization 1NF/2NF/3NF.
Key Points
- Reduce redundancy and update anomalies; 3NF common target
- Modeling: normalization 1NF/2NF/3NF
- Relevant areas: SQL, Modeling
- Use the answer to connect the concept back to a realistic production or interview scenario for 'Data modeling: normalization 1NF/2NF/3NF?'
Comparison / Tradeoffs
Aspect Notes Core idea Reduce redundancy and update anomalies; 3NF common target. Practical tradeoff Modeling: normalization 1NF/2NF/3NF. -
Most asked Indexing/performance: B-tree index?
Summary
Default for equality/range queries on ordered keys.
Longer Answer
Default for equality/range queries on ordered keys. Perf: B-tree index.
Key Points
- Default for equality/range queries on ordered keys
- Perf: B-tree index
- Relevant areas: SQL, Performance
- Use the answer to connect the concept back to a realistic production or interview scenario for 'Indexing/performance: B-tree index?'
Comparison / Tradeoffs
Aspect Notes Core idea Default for equality/range queries on ordered keys. Practical tradeoff Perf: B-tree index. -
Most asked Indexing/performance: EXPLAIN / EXPLAIN ANALYZE?
Summary
Inspect planned vs actual query execution.
Longer Answer
Inspect planned vs actual query execution. Perf: EXPLAIN / EXPLAIN ANALYZE.
Key Points
- Inspect planned vs actual query execution
- Perf: EXPLAIN / EXPLAIN ANALYZE
- Relevant areas: SQL, Performance
- Use the answer to connect the concept back to a realistic production or interview scenario for 'Indexing/performance: EXPLAIN / EXPLAIN ANALYZE?'
Comparison / Tradeoffs
Aspect Notes Core idea Inspect planned vs actual query execution. Practical tradeoff Inspect planned vs actual query execution. - SQL interview: explain SELECT filtering.
- SQL interview: explain NULL semantics.
- SQL interview: explain transactions.
- Data modeling: primary key?
- Data modeling: foreign key?
- Data modeling: many-to-many?
- Indexing/performance: composite index?
- Indexing/performance: index write overhead?
- SQL interview: explain RIGHT / FULL JOIN.
- SQL interview: explain ORDER BY / LIMIT.
- SQL interview: explain subqueries.
- SQL interview: explain CTEs (WITH).
- SQL interview: explain UNION vs UNION ALL.
- SQL interview: explain EXISTS vs IN.
- SQL interview: explain CASE expressions.
- SQL interview: explain dirty/nonrepeatable/phantom reads.
- Data modeling: denormalization?
- Data modeling: surrogate vs natural keys?
- Data modeling: OLTP vs OLAP?
- Data modeling: constraints?
- Indexing/performance: covering index?
- Indexing/performance: sequential vs index scan?
- Indexing/performance: cardinality?
- Indexing/performance: vacuum / analyze (Postgres)?
- SQL interview: explain CROSS JOIN.
- SQL interview: explain DISTINCT.
- Data modeling: star schema?
- Data modeling: 1:1 relationships?
- Indexing/performance: hash index?
- Indexing/performance: partial index?
- What are the different types of JOINs in SQL?
- Why are indexes important in a database?