PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/System Design/OpenAI

Design in-memory database API

Last updated: May 8, 2026

Quick Overview

This question evaluates a candidate's ability to design and reason about in-memory data storage, indexing, query planning, and the underlying data structures and algorithms for insert and query operations.

  • medium
  • OpenAI
  • System Design
  • Software Engineer

Design in-memory database API

Company: OpenAI

Role: Software Engineer

Category: System Design

Difficulty: medium

Interview Round: Technical Screen

##### Question Design and implement an in-memory database that supports: insert(table, record) query(table, columns_to_project, conditions=[(column, operator, value)], order_by=(columns, ascending)) Extend the design to explain how indexes would be built and used for faster WHERE and ORDER BY queries.

Quick Answer: This question evaluates a candidate's ability to design and reason about in-memory data storage, indexing, query planning, and the underlying data structures and algorithms for insert and query operations.

Related Interview Questions

  • Design a Distributed Crossword Solver - OpenAI (hard)
  • Design a Distributed Rate Limiter - OpenAI
  • Design a Distributed Crossword Solver - OpenAI (medium)
  • Design Mobile Model Usage Quotas - OpenAI (medium)
  • Design a Slack-Like Messaging System - OpenAI (medium)
OpenAI logo
OpenAI
Jul 29, 2025, 8:05 AM
Software Engineer
Technical Screen
System Design
30
0

In-Memory Database: Insert, Query, and Indexing

Context

You are to design a minimal, single-process, in-memory database to be embedded in a service. The database manages multiple named tables with simple schemas and must support:

  • write: insert(table, record)
  • read: query(table, columns_to_project, conditions=[(column, operator, value)], order_by=(columns, ascending))

Assume:

  • Records are dictionaries keyed by column name.
  • Each table has a defined schema (column names and basic types like int/float/string), but you may keep type handling simple.
  • Operators include: =, !=, <, <=, >, >=, IN (optional). Combine conditions with AND semantics.
  • order_by takes one or more columns and a boolean ascending flag.
  • Single-threaded execution is fine; you do not need transactions or persistence.

Tasks

  1. Design the in-memory data structures and algorithms to implement insert and query.
  2. Provide an implementation sketch (pseudocode or a compact, idiomatic language like Python/Go/Java) showing the core logic.
  3. Extend the design to explain how indexes would be built and used to speed up WHERE (conditions) and ORDER BY queries, including:
    • What index types you would support and why.
    • How inserts update indexes.
    • How the query planner chooses which index to use for different predicates and orderings.
    • Complexity trade-offs and edge cases.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More OpenAI•More Software Engineer•OpenAI Software Engineer•OpenAI System Design•Software Engineer System Design
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.