Software Engineer Interview Question

How do you decide between a relational database and a document store for a new service?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Start relational unless you have a specific reason not to. Postgres gives you transactions, joins, constraints and a query planner, which covers most workloads and keeps your options open. Reach for a document store when the access pattern is genuinely one key to one blob, when the schema really does vary per record, or when you need write throughput beyond what a single primary can handle.

Why interviewers ask this

The interviewer wants to see whether you choose infrastructure from requirements or from fashion. They are listening for an honest default, an understanding that relational databases scale further than people assume, and awareness that giving up joins and transactions is a real cost you pay later in application code. Candidates who say NoSQL is faster without qualifying it usually have not run either at scale.

How to structure your answer

  • State your default and why it is your default.
  • List the access patterns that would change your mind.
  • Name what you give up when you drop relational features.
  • Point out that data models outlive services.

Example answer

Spoken example, first person

My default is Postgres, and I want to be talked out of it rather than into it. The reason is that a relational database gives me transactions, joins and constraints for free, so I do not have to guess my access patterns correctly on day one. Data models outlive the services that write them, and I would rather keep flexibility in the query layer than in the storage layer. I do reach for a document store in specific cases. If each record is genuinely self contained, if the shape varies per tenant, or if I need write throughput past a single primary, the trade makes sense. What I try to be honest about is the cost: without joins, every relationship becomes application code, and without transactions, every multi document update becomes an idempotency problem. On my last project we kept core entities in Postgres and put a high volume event log somewhere built for that, which gave us scale where we needed it without giving up correctness everywhere else.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How far would you push a single Postgres instance before sharding?
  • How do you model a many to many relationship in a document store?
  • When would you use JSONB columns instead of a separate database?

Related software engineer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot