NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

Build a simple in-memory database that stores records under unique string keys. Each record consists of zero or more fields, with both field names and their values represented as strings.

Implement the InMemoryDB class:

  • void setData(String key, String field, String value) — stores the given value under field in the record identified by key.

    • If the field already exists, update its value.
    • If there is no record for the key, create one.
  • String getData(String key, String field) — retrieves the value of the specified field from the record identified by key.

    • Return "" if either the record or the field is missing.
  • boolean deleteData(String key, String field) — deletes the specified field from the record identified by key.

    • Return true if the field was deleted, or false if the key or field is absent from the database.
Test Cases
Input
Output
Expected