Execute In-Memory SQL Storage Operations
Reported by candidates from Fivetran's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Fivetran OA, reported September 2026, is treating it like a database problem when it's a bookkeeping problem. You get six operations, five parallel arrays, and up to 100000 rows of input. No SQL parsing, no real engine. Just nested hash maps and strict error rules. Candidates lose points by mutating state before checking whether the operation is valid, or by missing that INSERT is described as storing at a row ID given in ids[i]. If you've got the invite and 48 hours, this is a clean simulation. StealthCoder sits invisibly on your screen as a safety net if you blank during the live OA.
The problem
Execute a finite ordered batch against an in-memory database service. The five input arrays have equal length. Return one result per operation. CREATE_DB creates a database. CREATE_TABLE creates a table in an existing database. INSERT stores values[i] at a new integer row ID. READ returns the current value for an existing row. UPDATE replaces the value of an existing row. DELETE removes an existing row. A successful write returns OK. A missing parent, missing row, or duplicate create/insert returns ERROR and changes no state. Fields unused by an operation may contain the empty value for their type. Function executeStorageOperations(operations: String[], databases: String[], tables: String[], ids: int[], values: String[]) → String[] Examples Example 1 operations = ["CREATE_DB","CREATE_TABLE","INSERT","READ","UPDATE","READ","DELETE","READ"] databases = ["sales","sales","sales","sales","sales","sales","sales","sales"] tables = ["","orders","orders","orders","orders","orders","orders","orders"] ids = [0,0,7,7,7,7,7,7] values = ["","","new","","paid","","",""] return = ["OK","OK","OK","new","OK","paid","OK","ERROR"] The update changes the stored row and deletion removes it. Example 2 operations = ["CREATE_TABLE","CREATE_DB","CREATE_DB","CREATE_TABLE","INSERT","INSERT"] databases = ["x","x","x","x","x","x"] tables = ["t","","","t","t","t"] ids = [0,0,0,0,1,1] values = ["","","","","a","b"] return = ["ERROR","OK","ERROR","OK","OK","ERROR"] Parents must exist and duplicate creates or inserts fail. Example 3 operations = [] databases = [] tables = [] ids = [] values = [] return = [] An empty batch has no results. Constraints 0 <= operations.length <= 100000 and all five arrays have that length. Every operation is one of the six documented uppercase strings. Database and table names used by their operations are nonempty and at most 100 characters. Row IDs are nonnegative, and stored values have at most 1000 characters.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The structure is a map of database name to a map of table name to a map of row ID to value. Walk the arrays once, switch on the operation, and append one result per step. The trick is ordering: validate parents first, then check duplicate or missing rows, and only then write. An ERROR must change no state, so never create a parent as a side effect. Example 2 shows it: CREATE_TABLE before CREATE_DB returns ERROR and the database must still be absent afterward. Duplicate CREATE_DB must not wipe an existing database's tables. INSERT on an existing ID fails and keeps the old value. Watch for reading unused fields, since they can be empty strings or zero. Everything is O(1) average per operation, so 100000 ops is trivial. If you freeze on the live OA, StealthCoder gives you the nested-map skeleton so you can just check the edge cases.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Execute In-Memory SQL Storage Operations cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Fivetran's OA.
Fivetran reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Execute In-Memory SQL Storage Operations FAQ
How hard is this Fivetran OA problem really?+
Easy to medium. There's no clever algorithm, just careful simulation. Most failures come from missed edge cases like duplicate creates or operating on a missing table. If you can write nested hash maps and follow the spec literally, you'll finish quickly.
What's the trick to getting it right?+
Validate before you mutate. For every operation, check that the database exists, then the table, then the row condition, and only write if all pass. An ERROR must leave state untouched, so no auto-creating parents or overwriting existing rows.
What data structure should I use?+
A hash map from database name to a hash map from table name to a hash map from integer row ID to string value. Lookups and writes are O(1) average, which comfortably handles 100000 operations in one pass.
Which edge cases do people miss?+
Duplicate CREATE_DB wiping existing tables, INSERT on an existing ID overwriting the value, READ or DELETE after a row is already deleted, and the empty batch returning an empty array. Example 2 covers the parent-missing and duplicate cases directly.
How do I prepare for this in 48 hours?+
Write the nested-map solution from scratch once, then run the three given examples by hand. Add your own tests for delete-then-insert on the same ID and update on a missing row. That covers nearly every way this problem fails.