InterviewTreedInterviewTreed
All learning paths

Data, Cloud & DevOps

SQL & Database Design

Prepare for SQL and database interviews, covering query writing, joins, stored procedures, indexing, transactions, normalization, database architecture, and performance optimization.

Your learning roadmap

Explore the key concepts

Use these subtopics as a study checklist. Start with the fundamentals, then progress to practical examples and interview preparation.

Database fundamentals

Understand how databases store, organize, retrieve, and manage information, including tables, records, schemas, and basic database operations.

Start learning

Relational database concepts

Learn the relational database model, including tables, rows, columns, relationships, keys, and how data integrity is maintained through relational constraints.

Start learning

Database management systems (DBMS)

Explore database management systems, their architecture, storage engines, query processing, transaction management, and responsibilities in managing application data.

Start learning

SQL fundamentals

Learn Structured Query Language for creating, querying, modifying, and managing relational databases using standard SQL statements.

Start learning

SQL Server architecture

Understand SQL Server architecture, including the relational engine, storage engine, query processor, buffer pool, transaction log, and background services.

Start learning

DDL, DML, DCL, and TCL

Understand SQL command categories: DDL for schema definitions, DML for data manipulation, DCL for permissions, and TCL for transaction control.

Start learning

CREATE, ALTER, and DROP statements

Create, modify, and remove database objects using CREATE, ALTER, and DROP statements for tables, databases, indexes, and other schema components.

Start learning

INSERT, UPDATE, and DELETE statements

Modify table data using INSERT, UPDATE, and DELETE statements and understand filtering, multi-row operations, and safe data modification practices.

Start learning

SELECT queries

Retrieve data from relational tables using SELECT statements, including column selection, aliases, expressions, filtering, and result ordering.

Start learning

WHERE, ORDER BY, and DISTINCT

Filter query results with WHERE, sort records using ORDER BY, and eliminate duplicate rows with DISTINCT.

Start learning

GROUP BY and HAVING

Group records using GROUP BY and filter aggregated groups using HAVING to generate summarized reports and analytical query results.

Start learning

Aggregate functions

Use aggregate functions such as COUNT, SUM, AVG, MIN, and MAX to calculate summaries and perform grouped data analysis.

Start learning

String and date functions

Manipulate text and date values using SQL Server functions for formatting, extraction, conversion, comparison, and date calculations.

Start learning

CASE expressions

Write conditional SQL expressions using CASE to implement branching logic, categorize records, and calculate values based on business rules.

Start learning

NULL handling and NULL functions

Understand SQL NULL semantics and use IS NULL, ISNULL, COALESCE, and NULLIF to handle missing values and avoid unexpected query results.

Start learning

SQL joins

Combine related data from multiple tables using SQL joins and understand matching conditions, result sets, and relationship-based querying.

Start learning

INNER JOIN

Retrieve records with matching values in both tables using INNER JOIN and understand how join conditions affect the resulting dataset.

Start learning

LEFT and RIGHT JOIN

Use LEFT JOIN and RIGHT JOIN to preserve unmatched rows from one side of a relationship and identify missing related records.

Start learning

FULL OUTER JOIN

Combine matching and unmatched records from both tables using FULL OUTER JOIN and understand how NULL values represent missing matches.

Start learning

CROSS JOIN

Generate Cartesian products between tables using CROSS JOIN and understand practical use cases involving combinations and reference data.

Start learning

SELF JOIN

Join a table to itself using aliases to query hierarchical relationships, employee-manager structures, and comparisons between related records.

Start learning

Subqueries

Write nested SQL queries and use subqueries in SELECT, FROM, and WHERE clauses to filter, calculate, and retrieve related data.

Start learning

Correlated subqueries

Understand correlated subqueries that reference outer query columns and learn how they execute for related rows and compare with JOIN-based solutions.

Start learning

Common Table Expressions (CTEs)

Structure complex SQL queries using Common Table Expressions, improve readability, and reuse named query expressions within a statement.

Start learning

Recursive CTEs

Use recursive Common Table Expressions to traverse hierarchical data, organizational structures, category trees, and parent-child relationships.

Start learning

Temporary tables

Create and manage temporary tables in SQL Server using local and global temporary table syntax to store intermediate query results.

Start learning

Table variables

Use table variables to store temporary relational data and understand their scope, declaration, indexing options, and differences from temporary tables.

Start learning

UNION and UNION ALL

Combine result sets from multiple SELECT statements using UNION and UNION ALL and understand duplicate elimination and column compatibility requirements.

Start learning

EXCEPT and INTERSECT

Compare query result sets using EXCEPT and INTERSECT to identify rows present in one result but absent from or shared with another.

Start learning

Window functions

Analyze rows relative to other rows using SQL window functions and understand OVER, PARTITION BY, ORDER BY, and window frames.

Start learning

ROW_NUMBER, RANK, and DENSE_RANK

Assign sequential and ranking values to query results using ROW_NUMBER, RANK, and DENSE_RANK and understand how ties affect ranking.

Start learning

LEAD and LAG

Access values from subsequent and preceding rows using LEAD and LAG to compare records and analyze changes across ordered datasets.

Start learning

PARTITION BY and ORDER BY

Define logical groups and row ordering inside window functions using PARTITION BY and ORDER BY to perform calculations within data partitions.

Start learning

Running totals and moving averages

Calculate cumulative totals and rolling averages using window aggregates and appropriate window frames for reporting and time-series analysis.

Start learning

Pivot and Unpivot

Transform relational data between row-based and column-based layouts using PIVOT and UNPIVOT for reporting and analytical queries.

Start learning

Stored procedures

Create and execute stored procedures to encapsulate SQL logic, accept parameters, return results, and manage reusable database operations.

Start learning

User-defined functions

Create SQL Server user-defined functions to encapsulate reusable calculations and data transformations that can be called from SQL statements.

Start learning

Scalar and table-valued functions

Compare scalar and table-valued functions and learn how each returns individual values or relational result sets for reuse in queries.

Start learning

Triggers

Implement DML and DDL triggers to execute database logic automatically in response to INSERT, UPDATE, DELETE, and schema events.

Start learning

Views

Create and manage SQL views to encapsulate queries, simplify data access, provide abstraction, and control exposure of underlying table structures.

Start learning

Indexed views

Understand indexed views in SQL Server, including schema binding, clustered indexes, storage behavior, and their potential impact on query performance.

Start learning

Dynamic SQL

Build and execute SQL statements dynamically using EXEC and sp_executesql, handle parameters safely, and understand plan reuse and security risks.

Start learning

SQL variables and control flow

Declare and manage SQL variables and use IF, WHILE, BEGIN, END, BREAK, and other control-flow statements in SQL Server scripts.

Start learning

Cursors and alternatives

Understand SQL cursors for row-by-row processing and compare them with set-based operations, window functions, and other efficient alternatives.

Start learning

Transactions

Understand database transactions as units of work and learn how SQL Server manages atomic operations, consistency, isolation, and durability.

Start learning

ACID properties

Explore the ACID properties of database transactions: atomicity, consistency, isolation, and durability, and understand their role in reliable data processing.

Start learning

COMMIT and ROLLBACK

Control transaction outcomes using COMMIT and ROLLBACK and understand how to save successful operations or undo failed changes.

Start learning

Transaction isolation levels

Compare transaction isolation levels such as Read Uncommitted, Read Committed, Repeatable Read, Snapshot, and Serializable and understand their concurrency effects.

Start learning

Locking and blocking

Understand SQL Server locking mechanisms, lock modes, blocking sessions, and how concurrent transactions coordinate access to shared database resources.

Start learning

Deadlocks and deadlock prevention

Analyze database deadlocks, identify competing resource requests, interpret deadlock graphs, and apply strategies to reduce deadlock occurrences.

Start learning

Optimistic and pessimistic concurrency

Compare optimistic and pessimistic concurrency control and understand how version checks, locks, and conflict handling protect concurrent data updates.

Start learning

Database normalization

Understand database normalization and how organizing relational data reduces duplication, update anomalies, and unnecessary data dependencies.

Start learning

First, Second, and Third Normal Forms

Apply First, Second, and Third Normal Forms to eliminate repeating groups, partial dependencies, and transitive dependencies in relational database designs.

Start learning

BCNF

Understand Boyce-Codd Normal Form and identify functional dependencies that violate BCNF, including cases where Third Normal Form is insufficient.

Start learning

Database denormalization

Use denormalization techniques to improve read performance by introducing controlled redundancy and understand the trade-offs for consistency and maintenance.

Start learning

Primary and foreign keys

Define primary and foreign keys to uniquely identify records, enforce referential integrity, and establish relationships between relational tables.

Start learning

Unique and check constraints

Enforce data integrity using UNIQUE and CHECK constraints to prevent duplicate values and restrict stored data according to business rules.

Start learning

Database relationships

Model relationships between database entities and understand how keys and constraints represent connections between related tables.

Start learning

One-to-one, one-to-many, and many-to-many relationships

Design one-to-one, one-to-many, and many-to-many relationships and implement them using primary keys, foreign keys, and junction tables.

Start learning

Clustered and non-clustered indexes

Understand clustered and non-clustered indexes in SQL Server, how they organize data, and how index structures influence data retrieval.

Start learning

Unique and composite indexes

Create unique and composite indexes to enforce uniqueness and optimize queries that filter or sort using multiple columns.

Start learning

Covering indexes

Design covering indexes using key and included columns to satisfy query requirements and reduce additional table or index lookups.

Start learning

Index fragmentation and maintenance

Identify index fragmentation and understand index reorganizing, rebuilding, fill factor, and maintenance strategies for SQL Server databases.

Start learning

Index seek vs index scan

Compare index seeks and index scans and understand how SQL Server accesses indexed data based on predicates, selectivity, and query requirements.

Start learning

Execution plans

Read SQL Server execution plans to understand query operators, access methods, estimated and actual row counts, and performance bottlenecks.

Start learning

Query optimization

Optimize SQL queries by improving filtering, joins, indexing, query structure, and execution strategies to reduce resource consumption.

Start learning

SQL performance tuning

Diagnose and improve database performance through query analysis, index design, execution plans, statistics, waits, and workload monitoring.

Start learning

SARGable queries

Write Search ARGument Able queries that allow SQL Server to use indexes effectively by avoiding non-searchable predicates and unnecessary transformations.

Start learning

Statistics and cardinality estimation

Understand SQL Server statistics and cardinality estimation and learn how data distribution influences row estimates and query execution plans.

Start learning

Parameter sniffing

Understand parameter sniffing in SQL Server, how cached execution plans depend on parameter values, and techniques for diagnosing and managing plan issues.

Start learning

Query Store

Use SQL Server Query Store to capture query history, compare execution plans, analyze performance regressions, and manage plan forcing.

Start learning

Database partitioning

Organize large database tables and indexes into partitions to improve manageability, support maintenance operations, and optimize selected queries.

Start learning

Database sharding

Understand database sharding as a horizontal scaling strategy and explore shard keys, data distribution, routing, and cross-shard query challenges.

Start learning

Database replication

Explore database replication techniques for distributing data across servers and understand SQL Server replication types and synchronization behavior.

Start learning

Backup and recovery

Plan database backup and recovery using full, differential, and transaction log backups and understand restore sequences and recovery models.

Start learning

High availability and disaster recovery

Design database resilience using high-availability and disaster-recovery technologies, including failover strategies, recovery objectives, and data protection.

Start learning

SQL Server security

Secure SQL Server environments through authentication, authorization, encryption, auditing, network protection, and controlled database access.

Start learning

Users, roles, and permissions

Manage SQL Server access by creating database users, assigning roles, granting permissions, and applying least-privilege security principles.

Start learning

SQL injection prevention

Prevent SQL injection by using parameterized queries, safe dynamic SQL, input validation, stored procedures, and appropriate database permissions.

Start learning

Database encryption

Protect sensitive database information using encryption techniques such as Transparent Data Encryption, Always Encrypted, and encryption in transit.

Start learning

SQL Server Agent and scheduled jobs

Automate database administration using SQL Server Agent jobs, schedules, job steps, alerts, operators, and execution history.

Start learning

Database migrations

Manage database schema evolution through migration scripts, version control, deployment planning, rollback strategies, and application compatibility.

Start learning

Entity Framework Core and SQL integration

Integrate SQL Server databases with Entity Framework Core and understand entity mapping, LINQ translation, migrations, transactions, and query execution.

Start learning

ADO.NET database connectivity

Connect .NET applications to SQL databases using ADO.NET connection objects, commands, readers, parameters, transactions, and connection management.

Start learning

SQL coding interview problems

Practice SQL interview problems involving joins, subqueries, aggregation, ranking, duplicate detection, window functions, and query optimization.

Start learning

Real-world database design scenarios

Apply database design principles to practical business scenarios, including entity modeling, relationships, normalization, indexing, and data integrity.

Start learning

Practice & revise

Interview questions

Practice interview questions with answers, key points, and practical examples.

Test your knowledge

Explore 120 questions for this topic, covering concepts, practical examples, and interview scenarios.

Browse 120 questions

Keep learning step by step

Work through the concepts, practice explaining them in your own words, and use interview questions to check your understanding.

Explore another learning path