Store a DAG so ancestor and descendant queries are fast

MediumSystem design25 minSWEPro outline

The question

You store a large directed acyclic graph, for example model lineage or pipeline dependencies, in a database. Design storage so you can quickly find all ancestors and all descendants of a node.

What the interviewer is looking for

  • Compares adjacency lists, closure tables and graph databases
  • Explains recursive queries and their cost
  • Discusses write cost of maintaining a closure
  • Thinks about where computation runs to save round trips
  • Considers scale and hot nodes

Your answer

Saved in this browser only. Nobody else sees it.

Why this question

Written by BlogLLM in the style of a publicly reported Alibaba Qwen (Tongyi Lab) question type: store a DAG to answer all-ancestors and all-descendants queries; SQL execution with a WHERE clause; graph database versus MySQL.

Reported in: nowcoder.com

Practice question written by BlogLLM based on publicly reported interview formats. Not an official Alibaba Qwen (Tongyi Lab) question.