InterviewStack.io LogoInterviewStack.io

Relational Databases and SQL Questions

Focuses on relational database fundamentals and practical SQL skills. Candidates should be able to write and reason about SELECT queries, JOINs, aggregations, grouping, filtering, common table expressions, and window functions. They should understand schema design trade offs including normalization and denormalization, indexing strategies and index types, query performance considerations and basic optimization techniques, how to read an execution plan, and transaction semantics including isolation levels and ACID guarantees. Interviewers may test writing efficient queries, designing normalized schemas for given requirements, suggesting appropriate indexes, and explaining how to diagnose and improve slow queries.

HardTechnical
0 practiced
Explain isolation anomalies: dirty read, non-repeatable read, phantom read, and write skew. For each anomaly, provide a short SQL example (two concurrent transactions) that demonstrates it and recommend an isolation level or pattern to prevent it in a banking-style ETL that aggregates balances.
EasyTechnical
0 practiced
You are given a PostgreSQL table for customer records:
customers(
  customer_id INT PRIMARY KEY,
  name VARCHAR(100),
  email VARCHAR(255),
  signup_date DATE,
  is_active BOOLEAN
)
Write a PostgreSQL-compatible SQL query to return customer_id, name, email for customers who signed up in the last 30 days (relative to CURRENT_DATE) and whose is_active is true. State any assumptions about nulls and time zones and how you'd adapt the query if signup_date were TIMESTAMP WITH TIME ZONE.
EasyTechnical
0 practiced
Table: orders(order_id, customer_id, total_amount)
Write an SQL query that classifies each order as 'low', 'medium', or 'high' based on total_amount using CASE: low < 50, medium between 50 and 200 (inclusive), high > 200. Return order_id, total_amount, and category. Also describe when CASE vs mapping table is preferable for business rules.
EasyTechnical
0 practiced
You have a sales table:
sales(order_id INT, customer_id INT, order_date DATE, revenue NUMERIC)
Write an SQL query to return the top 10 customers by total revenue over the past year, showing customer_id and total_revenue, sorted descending. Explain how LIMIT (or TOP) and ORDER BY interact and what happens if two customers tie on revenue.
MediumTechnical
0 practiced
Explain the practical differences between Read Committed and Repeatable Read isolation levels. For a reporting job that reads transactional tables while the OLTP system is running, which isolation level would you choose to avoid partially inconsistent aggregates and why?

Unlock Full Question Bank

Get access to hundreds of Relational Databases and SQL interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.