Exercise 1: Testing getBreadcrumb() at Three Levels — Possible Solution ==================================================================== SETUP ------------------------------ id: 1, title: 'Programming', parent_id: NULL id: 2, title: 'General-Purpose Languages', parent_id: 1 id: 3, title: 'Java', parent_id: 2 async function getBreadcrumb(pool, pageId) { const [rows] = await pool.query(` WITH RECURSIVE ancestors AS ( SELECT *, 0 AS depth FROM pages WHERE id = ? UNION ALL SELECT p.*, a.depth + 1 FROM pages p INNER JOIN ancestors a ON p.id = a.parent_id ) SELECT * FROM ancestors ORDER BY depth DESC; `, [pageId]); return rows; } await getBreadcrumb(pool, 3); RESULT ------------------------------ [ { id: 1, title: 'Programming', depth: 2, ... }, { id: 2, title: 'General-Purpose Languages', depth: 1, ... }, { id: 3, title: 'Java', depth: 0, ... } ] - root-to-leaf order, exactly matching what every sibling course's own breadcrumb needed, produced here by a single query instead of three separate ones or a nested eager-load call. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly calls getBreadcrumb() with a real three-level-deep page ID, and correctly shows the resulting array in the proper root-to-leaf order the recursive CTE's own depth-based ordering produces.