Interview Q&A · questions with model answers

SQL & Databases Interview Questions

Part of the study plan for: Backend Engineer · Full Stack Engineer · Data Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked SQL interview: explain INNER JOIN.

    Returns matching rows from both tables on join predicate.

  2. Most asked SQL interview: explain LEFT JOIN.

    All left rows plus matches; NULLs when no match.

  3. Most asked SQL interview: explain GROUP BY.

    Aggregate per group; SELECT non-aggregates must be grouped.

  4. Most asked SQL interview: explain HAVING.

    Filter groups after aggregation.

  5. Most asked SQL interview: explain window functions.

    ROW_NUMBER/RANK/SUM OVER partitions without collapsing rows.

  6. Most asked SQL interview: explain ACID.

    Atomicity, Consistency, Isolation, Durability.

  7. Most asked SQL interview: explain isolation levels.

    Read uncommitted to serializable; trade consistency vs concurrency.

  8. Most asked Data modeling: normalization 1NF/2NF/3NF?

    Reduce redundancy and update anomalies; 3NF common target.

  9. Most asked Indexing/performance: B-tree index?

    Default for equality/range queries on ordered keys.

  10. Most asked Indexing/performance: EXPLAIN / EXPLAIN ANALYZE?

    Inspect planned vs actual query execution.

  11. SQL interview: explain SELECT filtering.

    WHERE filters rows before grouping; use AND/OR carefully with parentheses.

  12. SQL interview: explain NULL semantics.

    NULL means unknown; use IS NULL; aggregates ignore NULLs.

  13. SQL interview: explain transactions.

    BEGIN/COMMIT/ROLLBACK; ACID properties.

  14. Data modeling: primary key?

    Unique identifier for rows; often surrogate integer/UUID.

  15. Data modeling: foreign key?

    Referential integrity to another table's key.

  16. Data modeling: many-to-many?

    Resolved via junction/bridge table.

  17. Indexing/performance: composite index?

    Leftmost prefix rule matters for multi-column indexes.

  18. Indexing/performance: index write overhead?

    Indexes speed reads but slow writes and use space.

  19. SQL interview: explain RIGHT / FULL JOIN.

    Right keeps right side; FULL keeps both with NULLs for non-matches.

  20. SQL interview: explain ORDER BY / LIMIT.

    Sort and truncate result sets; note OFFSET costs.

  21. SQL interview: explain subqueries.

    Nested SELECT in WHERE/FROM/SELECT; correlated vs non-correlated.

  22. SQL interview: explain CTEs (WITH).

    Named subqueries improving readability; materialization varies by engine.

  23. SQL interview: explain CASE expressions.

    Conditional logic in SQL projections/aggregations.

  24. SQL interview: explain dirty/nonrepeatable/phantom reads.

    Anomalies prevented by higher isolation.

  25. Data modeling: denormalization?

    Intentional redundancy for read performance.

  26. Data modeling: constraints?

    UNIQUE, CHECK, NOT NULL enforce integrity in DB.

  27. Indexing/performance: covering index?

    Index includes all columns needed so heap fetch avoided.

  28. Indexing/performance: cardinality?

    Distinct value counts influence plans.

  29. Indexing/performance: vacuum / analyze (Postgres)?

    Reclaim dead tuples and refresh statistics.

  30. SQL interview: explain CROSS JOIN.

    Cartesian product; rarely intentional without filters.

  31. SQL interview: explain DISTINCT.

    Deduplicate rows; can be expensive—ensure need.

  32. Data modeling: star schema?

    Fact table + dimensions for analytics.

  33. Data modeling: 1:1 relationships?

    Separate table for optional/heavy attributes or security.

  34. Indexing/performance: hash index?

    Equality only (engine-specific caveats).

  35. Indexing/performance: partial index?

    Index subset of rows matching predicate.

Was this page helpful?

Report a mistake