solidcodersolidcoder
Explore Courses
solidcodersolidcoder
CoursesAboutPrivacy PolicyTerms
© 2026 solidcoder · Practical courses for software engineering interviews.
Home/Machine Coding/Machine coding Tutorial/Machine Coding Question: In-Memory SQL-Like Database
Chapters — Machine coding Tutorial▾

Machine Coding Question: In-Memory SQL-Like Database

Machine Coding·Machine Coding Questions·5 min read·Sep 6, 2026

Design an in-memory SQL-like database — Razorpay’s classic Machine Coding question: tables, schema, CRUD, validation, indexing and locking with example usage.

Asked inRazorpay

In this article, I want to give you a glimpse of what a machine coding question might look like. This question is one of the most popular ones asked in Razorpay interviews and serves as a great starting point for preparing for machine coding challenges. While the thought process behind addressing this question can come naturally, implementing the solution can be quite challenging.

What the round tests

The machine coding round typically involves solving a design problem within a few hours, where candidates are required to create a clean, modular, and extensible solution based on a specific set of requirements.

Objective

The primary objective of this project is to design and implement an in-memory SQL-like database that supports a range of functionalities. The database should be capable of managing tables and records efficiently while enforcing data integrity through validation rules.

Functional Requirements

Three tiers of scope

Requirements are split into three tiers so you know what to prioritize under time pressure: build first, build if time allows, and discuss only.

Part 1 — Basic Requirements

Core functionality you must build and get working first.

1. Table Management

Table operations
Capability
What it means
Create / Delete Tables
Allow users to create new tables, modify existing ones, or delete tables when they are no longer needed.
Define Tables with Schema
Users define tables via a schema of columns with specific data types (string and int) and constraints.

2. Column Constraints

Column rules
String — max length 20
String columns can support a maximum length of 20 characters.
Int — max value 1024
Integer columns can enforce a max value of 1024.

3. Data Operations

Operations
Operation
What it does
Insert / Update / Read / Delete
Add, modify, and remove records in tables.
Print All Records
Display all records within a specified table.
Querying — equal / not equal
Apply multiple filters on any columns within a single query to retrieve specific datasets.

4. Validation

Schema Validation

The system must raise errors during schema validation to catch issues like null values or out-of-range integers.

Part 2 — Bonus Features

Bonus — score higher if time allows

Extensibility checks — can your design handle change without a rewrite.

Bonus features
Feature
What to build
Indexing
Add indexing options on columns to improve query performance.
Locking Mechanisms
Introduce optimistic and pessimistic locking at the row level to ensure data integrity during concurrent access.

Part 3 — Future Features

Future — discuss, don't build now

Discuss-only evolution — how the system could grow next.

Future direction
Feature
Why it matters
Query Capability
Support SQL-based syntax so users can leverage familiar SQL commands and expressions for complex querying.
Multi-Column Indexing
Support indexing on multiple columns to further enhance query performance.

Example Usage: Full Walkthrough

Here's how an interviewer would run through the flow end-to-end, one operation at a time.

1. Create a table

createTable("employees", {
  name:       { type: "string", required: true,  maxLength: 20 },
  age:        { type: "int",    required: true,  min: 18, max: 60 },
  department: { type: "string", required: false, maxLength: 20 }
})

2. Insert valid records

insert("employees", ["Alice", 30, "Engineering"])  // ok
insert("employees", ["Bob", 45, "Marketing"])      // ok

3. Insert invalid records — trigger validation

insert("employees", ["Charlie", 17, "Sales"])      // → error: age < 18
insert("employees", ["Diana", 65, "HR"])           // → error: age > 60

4. Print all records

printAll("employees")

5. Filter with a query

query("employees", { department: "Engineering" })

6. Drop the table

dropTable("employees")
Result

Alice and Bob persist; Charlie and Diana are rejected. query({ department: "Engineering" }) returns only Alice.

Up next1/1
Part 2 · Machine Coding Questions
←
← Prev Chapter
Machine Coding vs LLD
5 min
This month's launch price
₹30,000₹3,000SOLID50 — 50% OFF

3 years access · 40+ lessons · AI assisted coding

Enroll Now →

Use code SOLID50 at checkout

On this page
  • Objective
  • Functional Requirements
    • Part 1 — Basic Requirements
    • Part 2 — Bonus Features
    • Part 3 — Future Features
  • Example Usage: Full Walkthrough