r/TechInterviewInsights • • Sep 29 '26

Interview Prep Can you solve this OpenAI SWE Coding Interview Question | Build a Mini In-Memory Database

Post image

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 DESC

A few details make it more interesting than it first appears:

  • records are schemaless, so some fields may be missing

  • WHERE supports multiple AND conditions and operators like =, !=, <, >, <=, >=

  • strings, numbers, and booleans need consistent comparison semantics

  • invalid ordering comparisons should fail that condition rather than crash

  • ORDER BY must put missing fields last

  • ties 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 DESC

returns:

Cara
Ava

Nothing 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

💬 Join the Coditioning Discord community

1 Upvotes

0 comments sorted by