Skip to Main Content
  • Questions
  • Creating hierarchy using a parent child table

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question.

Asked: May 22, 2025 - 5:48 pm UTC

Last updated: June 27, 2025 - 4:16 pm UTC

Version: 19c

Viewed 1000+ times

You Asked

hello guys,

I'm trying to create hierarchy using a parent child table for analytic view but I'm struggling.

the steps:

1. create a attribute dimension using the table --> (id,name,parent_id)
(I succeeded but idk the correct way for the parent child hierarchy).

2.create a hierarchy using the attribute dimension from previous step,
(i succeeded to create a regular hierarchy that isn't based on parent child)
idk how to do it, tried 3 chatbots and also oracle docs with no answer.


im doing this on toad 19 - oracle 19
hope someone can help me.

thanks!

and Chris said...

It appears that you want to build a hierarchy using a parent-child relationship across rows. For example, company org charts (manager -> employee) or bill of materials product hierarchies.

This is NOT how analytic view hierarchies work!

These are defined across columns within a row. The classic example is date components, e.g.

Day -> week -> month -> year (e.g. Day 10 -> Week 24 -> June -> 2025)

Which could be based on a table like

create table dates ( day int, week int, month varchar2(10), year int )


So to use analytic views, you need to pivot the data into a table with a column for each level in the hierarchy.

Post more details about your use case and provide examples (create table, insert into), and we'll do our best to help.

Rating

  (1 rating)

Comments

Connect by prior.

John, June 26, 2025 - 8:42 pm UTC

I've built this exact query a few times in the past. This documentation will help get what you're looking for in terms of a hierarchical order of tables by reference depth.

https://docs.oracle.com/cd/B12037_01/server.101/b10759/queries003.htm
Chris Saxon
June 27, 2025 - 4:16 pm UTC

The OP is asking about attribute dimensions - these are part of analytic views and a separate concept to connect by prior queries. I believe mixing up these concepts is part of the problem - though the OP would have to confirm that.