InterviewDB Experience

Inline Database: Build an In-Memory Key-Value Store with SQL-Like Query Support

Interview Experience

Round 1 Coding / SQL

Problem

Build an in-memory database that stores records as key-value rows with typed fields. Support inserting records, querying by field values, updating, and deleting — all through a simple API that mirrors SQL semantics.

python
class InlineDB:
    def __init__(self):
        ...
    def insert(self, table: str, record: dict) -> int:

**returns** row_id
        ...
    def select(self, table: str, where: dict = None,
               columns: list[str] = None) -> list[dict]:
        # where: {field: value} — equality filter
        ...
    def update(self, table: str, where: dict, new_values: dict) -> int:

**returns** count of updated rows
        ...
    def delete(self, table: str, where: dict) -> int:

**returns** count of deleted rows
        ...
    def count(self, table: str, where: dict = None) -> int:
        ...

Example

db = InlineDB()
db.insert("users", {"name": "Alice", "age": 30, "active": True})
db.insert("users", {"name": "Bob",   "age": 25, "active": False})
db.select("users", where={"active": True}, columns=["name","age"])
# -> [{"name":"Alice","age":30}]
db.update("users", where={"name":"Bob"}, new_values={"active":True})
db.count("users", where={"active":True})  -> 2
db.delete("users", where={"name":"Alice"}) -> 1

Follow-ups

  1. How would you add an index on a specific field to make select lookups O(1) instead of O(N)?
  2. How do you support compound WHERE conditions like age > 25 AND active = True?
  3. How would you implement transactions so a sequence of inserts/updates is atomic?
  4. How do you handle schema enforcement — rejecting records that are missing required fields?

Full Details

Round 1 Coding / SQL

Problem

Build an in-memory database that stores records as key-value rows with typed fields. Support inserting records, querying by field values, updating, and deleting — all through a simple API that mirrors SQL semantics.

python
class InlineDB:
    def __init__(self):
        ...
    def insert(self, table: str, record: dict) -> int:

**returns** row_id
        ...
    def select(self, table: str, where: dict = None,
               columns: list[str] = None) -> list[dict]:
        # where: {field: value} — equality filter
        ...
    def update(self, table: str, where: dict, new_values: dict) -> int:

**returns** count of updated rows
        ...
    def delete(self, table: str, where: dict) -> int:

**returns** count of deleted rows
        ...
    def count(self, table: str, where: dict = None) -> int:
        ...

Example

db = InlineDB()
db.insert("users", {"name": "Alice", "age": 30, "active": True})
db.insert("users", {"name": "Bob",   "age": 25, "active": False})
db.select("users", where={"active": True}, columns=["name","age"])
# -> [{"name":"Alice","age":30}]
db.update("users", where={"name":"Bob"}, new_values={"active":True})
db.count("users", where={"active":True})  -> 2
db.delete("users", where={"name":"Alice"}) -> 1

Follow-ups

  1. How would you add an index on a specific field to make select lookups O(1) instead of O(N)?
  2. How do you support compound WHERE conditions like age > 25 AND active = True?
  3. How would you implement transactions so a sequence of inserts/updates is atomic?
  4. How do you handle schema enforcement — rejecting records that are missing required fields?

About This Question

This is a candidate experience report from a notion interview during the phone round.

It covers the following topics: Coding, Onsite, Phone, Sql .