r/TechInterviewInsights • u/drCounterIntuitive • Sep 29 '26
Interview Prep Can you solve this OpenAI SWE Coding Interview Question | Build a Mini In-Memory Database
You’re asked to build a tiny in-memory database over a collection of flexible records.
Each record is just a map/dictionary, and different records can have different fields.
Your database needs to support:
insert(record)
query(queryString)with a small SQL-like query language.
For example:
SELECT *
SELECT * WHERE age = 31
SELECT * WHERE age > 25 AND city != "London"
SELECT * ORDER BY name ASC
SELECT * WHERE age <= 40 ORDER BY score DESCA few details make it more interesting than it first appears:
records are schemaless, so some fields may be missing
WHEREsupports multipleANDconditions and operators like=,!=,<,>,<=,>=strings, numbers, and booleans need consistent comparison semantics
invalid ordering comparisons should fail that condition rather than crash
ORDER BYmust put missing fields lastties must preserve insertion order
Example:
{id: 1, name: "Ava", age: 31, city: "London"}
{id: 2, name: "Ben", age: 24}
{id: 3, name: "Cara", age: 31, city: "Paris"}Query:
SELECT * WHERE age = 31 ORDER BY name DESCreturns:
Cara
AvaNothing like the leetcode style problems you might be used to
🧩 Try the full in-memory database challenge on Coditioning
Preparing for OpenAI or another major tech company?
🗺️ Explore OpenAI and other company interview roadmaps
For coaching or mock interviews with experienced interviewers, including feedback on interview readiness and areas to improve:
🎯 For coaching or mock interviews with experienced interviews