I have 3 tables: areas
, roles
and personas
. I generate a hierarchy based on them where personas
hang from their role, each role hangs from its area
, and all areas of a fixed tuple. The basic query that I leave as an example would be:
SELECT 'U' AS ID, NULL AS ID_PADRE, 'PADRE DE TODOS' AS DESCRIPCION FROM DUAL
UNION ALL
SELECT ('A_' || ID_AREA) AS ID, 'U' AS ID_PADRE, DESCRIPCION_AREA AS DESCRIPCION FROM AREAS
UNION ALL
SELECT ('R_' || ID_ROL) AS ID, ('A_' || ID_AREA_ROL) AS ID_PADRE, DESCRIPCION_ROL AS DESCRIPCION FROM ROLES R
UNION ALL
SELECT ('P_' || ID_PERSONA) AS ID, ('R_' || ID_ROL_PERSONA) AS ID_PADRE, NOMBRE AS DESCRIPCION FROM PERSONA
And it generates me a hierarchy of this type (people are not seen, but would hang from each of the roles that are underneath everything, such as " Driver ", " Nurse