Katkat

Store a hierarchy and return all children

AtlassianSoftware Engineer · Onsite

Last updated

This question evaluates understanding of hierarchical data modeling, REST API design, database schema choices (e.g., adjacency list vs alternatives), and systems-level concerns like scalability, pagination for large subtrees, and cycle prevention.

Design a service to store a hierarchical tree of nodes and expose APIs.

Requirements:

  • Persist a hierarchy (a forest with multiple roots is acceptable).
  • Support:
  1. Add a node under a parent.
  2. Return all descendants (all children recursively) of a given node.
  • Emphasis on REST API design, DB schema, and edge cases.

Deliverables:

  • API endpoints and example requests/responses.
  • Storage model choice (e.g., adjacency list, materialized path, nested sets, closure table) and justification.
  • How to handle large subtrees (pagination) and prevent cycles.