Design an In-Memory Database
ValonSoftware Engineer · Technical ScreenLast updated
This question evaluates a candidate's skills in data modeling, in-memory data structures, index design, and query/filter semantics for a flexible schema-less record store.
Implement a simple in-memory database with a flexible, schema-less record model.
Requirements:
- Each record is a mapping from
column_nametovalue. - The schema is not fixed: different records may contain different columns.
- A record may omit some columns entirely.
- Support inserting new records.
- Support querying by column name. At minimum, the system should be able to return the records that contain a given column, along with the stored value for that column.
- After implementing the core logic, create a few representative test cases yourself to demonstrate correctness.
Follow-up:
- Extend the query interface to support filtering, such as returning records that satisfy conditions on one or more columns.
- Because records may have missing fields, define and handle the behavior when a filter references a column that is absent in some records.
You may choose the exact API and internal data structures, but the design should make the operations above efficient and easy to test.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.