InterviewDB
Experience
Inline Database: Build an In-Memory Key-Value Store with SQL-Like Query Support
phone
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
- How would you add an index on a specific field to make
selectlookups O(1) instead of O(N)? - How do you support compound WHERE conditions like
age > 25 AND active = True? - How would you implement transactions so a sequence of inserts/updates is atomic?
- 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
- How would you add an index on a specific field to make
selectlookups O(1) instead of O(N)? - How do you support compound WHERE conditions like
age > 25 AND active = True? - How would you implement transactions so a sequence of inserts/updates is atomic?
- How do you handle schema enforcement — rejecting records that are missing required fields?
Free preview. Unlock all Notion questions →
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 .
More Notion Interview Questions
InterviewDB
Chat Service: Implement a Multi-Room Chat Backend with Message History
InterviewDB
Mobile Logging Library: Design a Thread-Safe In-App Logger for Android and iOS
InterviewDB
Notion SWE Phone - Document Store
InterviewDB
JSON Display: Render Nested JSON as a Collapsible Tree in the Browser
InterviewDB
Mobile TODO App: Implement a Persistent TODO List with Offline Sync on Android/iOS