Database Developer interview questions and how to answer them

A database developer interview is really about one thing: can you write SQL that stays correct and fast after the table grows and the requirements change? You'll write queries live, sketch a schema, and read an execution plan out loud. The DBA keeps the server alive, but you own what runs on it, so expect questions about design choices and the code you've shipped.

The process

What happens in each round

  1. 1

    Recruiter screen

    What happens

    Which engines you've written code for (SQL Server, PostgreSQL, Oracle, MySQL), whether you've worked in T-SQL or PL/SQL, and if you've supported reporting, an application backend, or both. Keep answers short and match your words to the posting.

  2. 2

    Live SQL exercise

    What happens

    Joins, grouping, window functions and handling NULLs, usually in a shared editor or on a sample dataset. They're watching how you check your own result, not just whether the query runs. Talk while you type.

  3. 3

    Schema design session

    What happens

    You get a loose business problem, like orders and returns or patient appointments, and design tables for it. They want keys, constraints, and a clear reason for every place you chose not to normalize.

  4. 4

    Hiring manager and team

    What happens

    How you work with application developers, the DBA and analysts. Expect stories about a migration that went sideways, a slow report you fixed, and how you review someone else's SQL without making enemies.

Questions you're likely to get

1.Walk me through how you'd speed up a query that suddenly got slow.

Why they ask

This is the job on a bad afternoon. They want a method, not a lucky guess about adding an index.

How to answer

  • Start by getting the actual execution plan, not the estimated one, and compare it to what ran before if you have it
  • Look for scans on large tables, bad row estimates, key lookups and implicit conversions in the WHERE clause
  • Check whether stale statistics or parameter sniffing changed the plan, before touching the code
  • Change one thing at a time and measure reads and duration, then explain the fix to whoever reported it
2.Design the tables for a system where customers place orders, and orders can be partly returned.

Why they ask

Returns break naive designs. They want to see if you model the real business event instead of flipping a status flag.

How to answer

  • Separate customers, orders, order lines and returns, with a return line table that points at the original order line
  • Use foreign keys and check constraints so a return can't exceed what was bought
  • Store the price at the time of sale on the order line rather than joining to the current product price
  • Say out loud which questions this design answers easily and which reports would need a view or summary table
3.When would you put logic in a stored procedure, and when would you keep it in the application?

Why they ask

Every team has an opinion here, and they want to know yours will fit or at least be argued well.

How to answer

  • Procedures earn their place for set-based work, batch jobs, and logic that several apps must run the same way
  • Business rules that change often or need unit tests in the app's language usually belong in the application
  • Mention how procedures get versioned, reviewed and deployed, since that's where they tend to rot
  • Give a real example where you moved logic one way and why
4.Explain the difference between a clustered and a nonclustered index, and how you choose the clustering key.

Why they ask

Indexing is the everyday craft of this role. A shaky answer here tells them most of what they need to know.

How to answer

  • The clustered index is the table's physical order, so there's only one, while nonclustered indexes are separate structures pointing back to it
  • A good clustering key is narrow, unique, stable and usually ever-increasing
  • Covering indexes with included columns can remove lookups, but every index costs you on inserts and updates
  • Note that PostgreSQL handles this differently, if you've worked there, and you'll look like you've used both
5.Write a query that returns each customer's most recent order.

Why they ask

It's a classic because there are several right answers and a few quietly wrong ones.

How to answer

  • Use ROW_NUMBER partitioned by customer and ordered by order date descending, then filter to the first row
  • Mention ties: if two orders share a timestamp, decide whether you want both and use RANK or add a tiebreaker
  • Offer an alternative with a correlated subquery or CROSS APPLY and say when you'd prefer it
  • Check the result against a customer you can verify by hand
6.How do you ship a schema change to a large production table without taking the app down?

Why they ask

Database developers own migrations. A careless ALTER on a busy table is a classic way to cause an outage.

How to answer

  • Break it into steps: add the new column as nullable, backfill in small batches, then add constraints
  • Keep old and new shapes working together so the app can deploy before or after the database
  • Use a migration tool like Flyway, Liquibase or SSDT and keep scripts in source control
  • Plan the rollback and test the whole thing against a copy of production-sized data first
7.What transaction isolation level do you usually work with, and when have you changed it?

Why they ask

Blocking and deadlocks often trace back to code the developer wrote. They want to know you understand why.

How to answer

  • Name the default for your engine, like read committed, and what it does and doesn't protect you from
  • Explain dirty reads, non-repeatable reads and phantoms in plain terms with a quick example
  • Describe a time you used snapshot isolation or tightened isolation for a specific process
  • Mention keeping transactions short and touching tables in a consistent order to avoid deadlocks
8.An analyst says the numbers in a report you built don't match finance's spreadsheet. What do you do?

Why they ask

A lot of database development feeds reports. Trust in the data is part of the job, and so is handling the conversation.

How to answer

  • Get one specific example that differs, like a single account and month, instead of chasing totals
  • Trace that row through your joins and filters, looking for duplicate joins, time zone cutoffs and excluded statuses
  • Agree on the definition with finance, since the gap is often a business rule nobody wrote down
  • Fix the code or document the difference, then add a check so it doesn't drift again
9.How do you test your SQL before it reaches production?

Why they ask

Database code is famously undertested. Someone who has a real habit here saves the team pain.

How to answer

  • Run against realistic data volumes, not a table with a handful of rows
  • Use a framework like tSQLt or pgTAP for procedures with real logic, or at least scripted before-and-after checks
  • Get code review on SQL the same way the app team reviews code
  • Compare results between the old and new version of a query when you refactor
10.Tell me about a time you pushed back on a design from an application developer.

Why they ask

You'll sit between app teams and the data. They want someone who can say no to a bad pattern without starting a feud.

How to answer

  • Pick a real case, like an ORM generating a query per row in a loop or storing lists in a comma-separated column
  • Show the evidence you brought, such as the execution plan or a test with real volume
  • Offer an alternative that still met their deadline
  • Say what happened after, including if you were partly wrong
11.What's the worst mistake you've made in a production database?

Why they ask

Everyone who's done this job has one. They're testing honesty and what you changed afterward.

How to answer

  • Name it plainly, like an UPDATE missing a WHERE clause or a migration that locked a table at peak
  • Explain how you noticed and how it got fixed, including who you told and how fast
  • Describe the habit you built from it, such as wrapping manual changes in a transaction and checking row counts first

Mistakes that sink good candidates

Writing a live query without checking the output, even when it runs without errors

Talking about indexes and performance without ever mentioning the execution plan

Describing yourself as a DBA when the role is development, or the reverse, which makes them wonder if you read the posting

Dismissing the app team or the analysts in your stories, since you'll work with them every day

Need more Database Developer interviews to prep for?

HeroApply applies to Database Developer jobs that match you, every day. 106 jobs are open today.

Find Database Developer jobs