Database analyst interview questions and how to answer them
Database analyst interview questions check that you know how a business's data is structured, can query it accurately, and can keep its contents consistent as applications and requests change. Expect a live or written SQL test, questions on keys, constraints and normalization, scenarios about bad or missing records, and questions on turning a user's request into a schema change, view or extract. It is a hands-on role, so interviewers listen for how you verify your own results.
By Evin JohnPublished 7 min read
What a database analyst does
Database analysts work in government agencies, hospitals, universities, insurers, retailers and software vendors, usually attached to one or two line-of-business systems: a student information system, a claims platform, an ERP, a case management tool. Typical work includes writing queries and extracts for other teams, profiling data before a change, specifying new tables or fields, building views and stored procedures that reports depend on, maintaining the data dictionary, and investigating when a user says a record looks wrong.
It overlaps with other roles but is not the same. A database administrator keeps the engine secure, backed up and fast. A data analyst uses the data to answer business questions. The database analyst sits between them: close enough to the schema to propose changes, close enough to users to know what the fields are supposed to mean.
How the interview process usually runs
- ScreenWhich database platforms you have used (SQL Server, Oracle, PostgreSQL, MySQL or others), the systems you supported and the kinds of requests you handled.
- SQL assessmentA timed online test or a shared editor. Expect three to six tasks on a small schema such as customers, orders and payments, or patients, visits and providers.
- Technical interviewQuestions on keys, constraints, normalization, indexes and transactions, plus a walk through how you would answer a messy request.
- Team and user interviewAnalysts, developers or business users. They check how you gather requirements, document changes and explain data limits in plain words.
SQL questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| List orders whose customer no longer exists. | Orphan detection | A LEFT JOIN to the parent with an IS NULL filter, or NOT EXISTS, and a note on why a foreign key would have prevented it. |
| Find people entered twice under slightly different names. | Duplicate logic | Grouping on normalized fields (trimmed, lower-cased email or date of birth plus surname), and honesty that fuzzy matches need human review. |
| Update prices for one category without touching the rest. | Safe changes | Running the matching SELECT first, checking the count, wrapping the UPDATE in a transaction and keeping a way back. |
| Show each customer's most recent order. | Latest row per group | ROW_NUMBER over a partition ordered by date, or a join to a grouped MAX, with a stated rule for ties. |
| Count records per month, including months with none. | Gaps | A calendar table or generated series joined on the left, so empty months show zero instead of vanishing. |
| Why does this report double some totals? | Join grain | Spotting a one-to-many join before a SUM and fixing it by aggregating first or joining at the right level. |
| Write a view the finance team can query safely. | Abstraction | Clear column names, filters for active records, no SELECT star, and permissions granted on the view rather than base tables. |
| What is wrong with NOT IN when the subquery has NULLs? | NULL handling | Any NULL in the list makes the condition unknown for every row, so the query returns nothing. NOT EXISTS avoids it. |
-- 1. Orders with no matching customer
SELECT o.order_id, o.customer_id
FROM orders o
LEFT JOIN customers c ON c.customer_id = o.customer_id
WHERE c.customer_id IS NULL;
-- 2. Customers sharing the same normalized email
SELECT LOWER(TRIM(email)) AS email_key, COUNT(*) AS customers
FROM customers
WHERE email IS NOT NULL
GROUP BY LOWER(TRIM(email))
HAVING COUNT(*) > 1;Design, keys and integrity questions
- Primary key, unique constraint and foreign key: what does each protect? A primary key identifies each row, a unique constraint stops duplicates in other columns, and a foreign key stops rows that point at nothing. Each one turns a rule people forget into a rule the database enforces.
- Natural key or surrogate key? Natural keys such as an email can change or be reused; surrogate keys stay stable. A common pattern is a surrogate primary key plus a unique constraint on the natural one.
- Explain first, second and third normal form in plain terms. One value per field, every column depends on the whole key, and no column depends on another non-key column. Give a small example such as storing a customer's city on every order row.
- When is denormalizing acceptable? For reporting tables or read-heavy views where the cost of joins matters more than the risk of update anomalies, and with a process that keeps the copies in step.
- A user wants a new field added to a core table. What do you ask? What decision the field serves, who maintains it, allowed values, whether it already exists elsewhere, the effect on existing reports and interfaces, and how old rows get a value.
- What is a check constraint, and give a useful one? A rule the row must satisfy, such as an end date on or after the start date, or a status limited to a known list.
- How do indexes help and hurt? They speed up reads on the indexed columns and slow down writes, take space, and can be ignored if the query wraps the column in a function.
- What does a transaction guarantee? That a group of changes is applied completely or not at all, and isolated from other sessions to the degree the isolation level sets.
Scenario questions
| Scenario | What it tests | What a strong answer covers |
|---|---|---|
| Two departments report different headcounts from the same system. | Definitions | Lining up filters, dates and status codes behind each number, then agreeing one definition and recording it in the dictionary. |
| Records disappeared from a report after last night's release. | Investigation | Checking whether the rows are gone or filtered out, comparing the view before and after the change, and looping in the developer with evidence. |
| A user asks for every field on every customer, exported weekly. | Requirements and privacy | Asking what the export is for, trimming it to needed fields, checking sensitivity and access rights, and automating only once the need is clear. |
| You must move ten years of records into a new system. | Migration validation | Profiling the source, mapping fields with transformation rules, running trial loads, and reconciling counts and key totals table by table. |
| An application team wants to drop a column you think reports use. | Impact analysis | Searching views, procedures, report definitions and scheduled extracts for the column before agreeing, and planning a deprecation window. |
| A batch update ran against the wrong year. | Recovery | Stopping further runs, finding affected rows from logs or audit columns, restoring values from a backup or history table with the DBA, and adding a guard. |
Fictional example
- At a county agency, caseworkers reported that some open cases were missing from their weekly list. I pulled the list's view definition and saw it joined cases to an assignments table with an inner join. Cases waiting for a caseworker had no assignment row, so they dropped out. I showed the team lead a count: 212 open cases were invisible that week. I changed the view to a left join with a clear 'unassigned' label, tested it against a copy with known cases, and added the rule to the data dictionary. The unassigned group became its own line on the report, and the supervisors began using it to balance workloads.
Documentation, tools and working style
- How do you keep a data dictionary accurate after schema changes?
- Which tools do you use to explore an unfamiliar database? (SSMS, DBeaver, pgAdmin, Oracle SQL Developer or similar, plus reading system tables for columns and keys.)
- How do you version the SQL you write for views and procedures?
- How do you test a change before it reaches production data?
- Describe a time you pushed back on a request because it would have harmed data quality.
- How do you explain to a manager why the number they want cannot be produced from the current data?
- How do you prioritize ad hoc extracts against planned work?
- DELETE, TRUNCATE and DROP: what does each remove, and why does the answer on rolling back depend on the platform?
For the behavioral part, the behavioral question guide covers the story structure. Database analysts score well when a story ends with a control that now prevents the problem, such as a constraint, a check query or a review step.
A one-week preparation plan
- Days 1 to 3: write queries by hand for orphans, duplicates, latest row per group, gaps by month and safe updates. Check each result count against what you expect.
- Day 4: revise keys, constraints, normalization, indexes and transactions until you can explain each in two sentences with an example.
- Day 5: practice two scenarios aloud: a disagreement between reports and records that vanished after a release.
- Day 6: prepare two stories about investigations you led and one about a change request you shaped.
- Day 7: read the job posting for platform names and systems, and prepare questions about how schema changes are approved.
Natively, an AI interview assistant for Mac and Windows, is useful for rehearsing the spoken part of this interview. It transcribes a mock session on your computer and can suggest talking points as questions arrive, using the CV and job description you add on Pro or the free trial. In practice it can also read a SQL task from a screenshot and walk through an approach, which helps you check whether you remembered NULL handling and row counts before answering.
Questions people ask
What questions are asked in a database analyst interview?
Expect a SQL test on joins, grouping, duplicates and orphan records, questions on keys, constraints, normalization, indexes and transactions, and scenarios such as reports that disagree or records that vanished after a release.
What is the difference between a database analyst and a database administrator?
A database administrator runs the database engine: backups, security, availability and performance. A database analyst works on what is inside it: structure, contents, queries, views, extracts and data integrity for the business.
How do I prepare for a database analyst SQL test?
Practice writing queries by hand for orphan rows, duplicates, the latest row per group, monthly counts with gaps and safe updates, and check every result count against what you expected.
What skills does a database analyst need?
Strong SQL, a solid grasp of relational design and constraints, careful testing habits, documentation, and the ability to turn a vague user request into a precise query, view or schema change.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
