SQL & Enterprise Databases

FlowCadaxEnterprise Automation & AI
BusinessLearning
Log inApply for admission
Curriculum67Interview Q/A36Projects8Cheatsheet
Loading technical interview battlecards...
Enterprise RDBMS & SQL Production Standard

SQL & Enterprise Databases Interview Hub

Real questions on indexing, execution plans, ACID anomalies and outbox patterns. Each one carries the senior answer and the reply that costs you the offer.

36 questions6 categories5 beginner17 intermediate14 advanced

Read these free

7 of 36 · full senior answers
IntermediatearchitectureCore SQL & Relational Architecture Scenarios#1

What is the exact logical order of execution for a SQL SELECT query?

Senior Answer Formulation:

The logical processing order is: 1. FROM (including JOINs), 2. ON (join conditions), 3. WHERE (row-level filtering), 4. GROUP BY (row aggregation), 5. HAVING (aggregate filtering), 6. SELECT (projections & window functions), 7. DISTINCT (deduplication), 8. ORDER BY (sorting), 9. LIMIT / OFFSET (pagination). Understanding this explains why column aliases defined in SELECT cannot be referenced in WHERE, but can be used in ORDER BY.

Senior Interviewer Pro-Tip:
Attempting to use column aliases in the WHERE clause. · Confusing the order of WHERE and HAVING.
AdvancedscenarioCore SQL & Relational Architecture Scenarios#2

How does three-valued logic in SQL affect queries with NOT IN and NULL values?

Senior Answer Formulation:

SQL uses three-valued logic: TRUE, FALSE, and UNKNOWN (NULL). When evaluating 'value NOT IN (1, 2, NULL)', the engine expands this to 'value != 1 AND value != 2 AND value != NULL'. Because any comparison with NULL yields UNKNOWN, and AND with UNKNOWN yields UNKNOWN (not TRUE), the entire expression evaluates to UNKNOWN. Consequently, the query returns zero rows. The best practice is to use NOT EXISTS or ensure NULLs are explicitly filtered with IS NOT NULL.

Senior Interviewer Pro-Tip:
Using NOT IN against a subquery that returns even a single NULL value, resulting in unexpected empty results.
AdvancedscenarioCore SQL & Relational Architecture Scenarios#3

Explain the difference between 2NF, 3NF, and BCNF normalization with a real-world scenario.

Senior Answer Formulation:

1NF requires atomic values and no repeating groups. 2NF requires 1NF plus NO partial dependencies (every non-key attribute must depend on the whole primary key, relevant for composite keys). 3NF requires 2NF plus NO transitive dependencies (non-key attributes cannot depend on other non-key attributes, e.g., zip_code determining city). Boyce-Codd Normal Form (BCNF) is a stricter version of 3NF where every determinant (X in X -> Y) must be a candidate key, eliminating anomalies in tables with multiple overlapping composite candidate keys.

Senior Interviewer Pro-Tip:
Assuming 3NF and BCNF are identical. · Over-normalizing read-heavy analytical reporting databases.
IntermediatescenarioCore SQL & Relational Architecture Scenarios#4

Why does adding a WHERE filter on a right table convert a LEFT JOIN into an INNER JOIN?

Senior Answer Formulation:

In a LEFT JOIN, rows from the left table with no right table match produce NULL for all right table columns. If you add 'WHERE right_table.status = 'ACTIVE'', the engine evaluates 'NULL = 'ACTIVE'' for unmatched rows, which evaluates to UNKNOWN (treated as FALSE in WHERE). Thus, all unmatched left rows are discarded, turning the query into an effective INNER JOIN. To preserve unmatched left rows, the right table filter must be placed inside the ON clause: 'LEFT JOIN right_table ON left.id = right.left_id AND right.status = 'ACTIVE''.

Senior Interviewer Pro-Tip:
Placing right-table filter predicates in the WHERE clause instead of the JOIN ON clause.
BeginnerarchitectureCore SQL & Relational Architecture Scenarios#5

Contrast DELETE, TRUNCATE, and DROP across transaction rollback capability, triggers, and space deallocation.

Senior Answer Formulation:

DELETE is a DML command that removes rows conditionally, fires table triggers, logs each row removal to WAL/redo logs, and can be rolled back. TRUNCATE is a DDL command that deallocates all data pages immediately, resets auto-increment sequences, does NOT fire individual row triggers, logs only page deallocations (vastly faster), and can be rolled back in PostgreSQL (not in MySQL). DROP is a DDL command that deletes both the data and the schema catalog definition, dropping all associated indexes and constraints.

Senior Interviewer Pro-Tip:
Running DELETE without a WHERE clause instead of TRUNCATE for staging tables, exhausting transaction log storage.
IntermediatescenarioCore SQL & Relational Architecture Scenarios#6

How do you find the Nth highest salary in a company using standard ANSI SQL?

Senior Answer Formulation:

The most robust, production-grade method uses the DENSE_RANK() window function inside a Common Table Expression (CTE): WITH RankedSalaries AS (SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rank_pos FROM employees) SELECT salary FROM RankedSalaries WHERE rank_pos = N LIMIT 1. DENSE_RANK() correctly handles ties without skipping ranks (e.g. if two employees tie for 1st, the next highest is 2nd). Alternative methods like LIMIT 1 OFFSET (N-1) fail if multiple employees share the top salaries.

Senior Interviewer Pro-Tip:
Using OFFSET (N-1) without accounting for duplicate salary ties. · Using RANK() instead of DENSE_RANK().
AdvancedscenarioQuery Optimization, Indexes & Execution Plan Defense#7

What is an Index-Only Scan (Covering Index) and why is it the holy grail of SQL performance?

Senior Answer Formulation:

An Index-Only Scan occurs when a database query can be satisfied entirely from the leaf pages of an index without visiting the underlying table data pages (heap). Because the index contains all columns requested in the SELECT projection and WHERE predicates, disk I/O is reduced by 90%+. In PostgreSQL and SQL Server, this is achieved using the INCLUDE clause (e.g. CREATE INDEX idx ON orders (customer_id, status) INCLUDE (total_amount)), which stores total_amount at leaf level without including it in the B-Tree search key.

Senior Interviewer Pro-Tip:
Using SELECT * which forces the engine to read the table heap, defeating the covering index.

What else is inside

29 more questions across 6 categories
1Core SQL & Relational Architecture Scenarios1320
2Query Optimization, Indexes & Execution Plan Defense245
3ACID Transactions, Concurrency, Deadlocks & Automation156
4SQL Fundamentals & Beginner Essentials426
5Joins, Subqueries & Data Relationships66
6Window Functions, CTEs & Advanced Analytical SQL336
Enrolled Students Only
Admission opened by the founder

Unlock all 36 interview questions

Every senior answer formulation, the production scenario behind it, and the What-To-Say / What-Not-To-Say battlecard — included on both admission pathways.

221 In-Depth Lessons: REFramework, Orchestrator, LINQ, Document Understanding
54 Full Capstones: Downloadable production Studio workflows & templates
280 Architecture Scenarios: Senior technical interview Q&A tested at Deloitte & PwC
Developer Cheatsheets & Certificate: Add verifiable badge to LinkedIn & Resume
No subscription · no card on file
Apply for admissionSee what is included
Your login is created by hand once you and Lokesh have spoken

See everything included in this track