Script Valley
Interview Prep: System Design Rounds
Databases and Storage Systems/Assessment

Practice & Assessment

Test your understanding of Databases and Storage Systems

Multiple Choice Questions

6
1

Which database type is best suited for a system that needs to store user activity events (100,000 writes/second) and query them by time range?

2

What problem does asynchronous replication introduce that synchronous replication avoids?

3

Why is using created_at as a shard key generally a bad idea for a high-write system?

4

A composite index exists on (user_id, created_at). Which query will NOT use this index efficiently?

5

Which storage type should you use for a database server running PostgreSQL?

6

What is a 'covering index' and why is it faster?

Coding Challenges

1
1

Query Shard Router

Implement a shard router that determines which shard(s) a query must be sent to. You have 4 shards. Records are sharded by hash(user_id) % 4. Implement three functions: getShardForUser(userId) returns shard index 0-3 for a single user lookup; getShardsForQuery(queryType, params) returns list of shard indices given queryType ('by_user' with userId param returns single shard; 'by_date_range' returns all 4 shards since date is not a shard key; 'all' returns all 4). Also implement addShard() which increases shard count to 5 and returns a mapping object showing which user IDs would move shards: { movedCount, percentMoved, example: [{userId, oldShard, newShard}] } for 5 example user IDs. Input: function calls with parameters. Output: shard index or array of indices. Estimated time: 20 minutes.

Medium

Mini Project

1

Database Selection Advisor CLI

Build a CLI tool that asks a series of questions about the user's system requirements and recommends the right database(s). Questions must cover: expected write QPS, read/write ratio, whether data is relational, whether schema is fixed, consistency requirements (strong/eventual), and whether global distribution is needed. Based on answers, output a ranked list of database recommendations (from the set: PostgreSQL, MySQL, Cassandra, MongoDB, Redis, DynamoDB, Neo4j, Elasticsearch) with reasoning for each recommendation and one specific trade-off to watch out for. Also output a suggested architecture snippet showing how the recommended database connects to the system (as ASCII art or a text diagram). Include at least 3 test scenarios in a scenarios.json file that the tool can run in demo mode.

Medium
Practice & Assessment โ€” Databases and Storage Systems โ€” Interview Prep: System Design Rounds โ€” Script Valley โ€” Script Valley