Organization Hierarchy
Data Entity
Description
Represents the parent-child relationships between organizations in a multi-tenant hierarchy, enabling NHF-style structures with national, regional, and local levels. Each record captures one edge in the hierarchy tree.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key | PKrequiredunique |
parent_organization_id |
uuid |
FK to organizations.id — the ancestor organization in this hierarchy edge | required |
child_organization_id |
uuid |
FK to organizations.id — the subordinate organization in this hierarchy edge | required |
hierarchy_level |
enum |
Semantic level of the child in the org tree (e.g. national, regional, local) | required |
depth |
integer |
Numeric depth from root (0 = top-level/national). Used for efficient subtree queries without recursive CTE on every request. | required |
path |
text |
Materialized path string (e.g. 'nhf/nhf-oslo/nhf-oslo-vest') for efficient ancestor/descendant lookups without recursion | required |
is_active |
boolean |
Whether this hierarchy link is currently active. Inactive links are hidden from navigation but preserved for audit. | required |
activity_distribution_enabled |
boolean |
Whether activities logged by child org members can roll up into parent org reports. Supports NHF requirement for activity distribution between org levels. | required |
max_child_memberships |
integer |
Maximum number of local associations a user can belong to under this parent (NHF: up to 5). NULL means unlimited. | - |
created_by |
uuid |
FK to users.id — Global Admin or Org Admin who created this hierarchy link | required |
created_at |
datetime |
Timestamp of record creation | required |
updated_at |
datetime |
Timestamp of last update | required |
Database Indexes
idx_org_hierarchies_parent
Columns: parent_organization_id
idx_org_hierarchies_child
Columns: child_organization_id
idx_org_hierarchies_unique_edge
Columns: parent_organization_id, child_organization_id
idx_org_hierarchies_path
Columns: path
idx_org_hierarchies_depth
Columns: depth
Validation Rules
child_differs_from_parent
error
Validation failed
unique_parent_child_pair
error
Validation failed
valid_hierarchy_level
error
Validation failed
depth_consistent_with_parent
error
Validation failed
both_orgs_must_exist
error
Validation failed
Business Rules
no_circular_hierarchy
A child organization cannot also be an ancestor of its parent in the same hierarchy tree. Circular references must be rejected.
max_membership_cap
When max_child_memberships is set on a hierarchy node, users may not be members of more child organizations under this parent than the cap allows. NHF cap is 5.
activity_rollup_requires_flag
Activity data from child organizations only rolls up into parent org reports when activity_distribution_enabled is true on the hierarchy edge.
global_admin_only_create_top_level
Only Global Admins may create or modify hierarchy edges at depth 0 (national level). Org Admins may only manage hierarchy below their own organization.
deactivate_cascades_to_reports
When a hierarchy edge is set inactive, parent org reports no longer include child data, and Bufdir exports exclude the child org's activities.
path_auto_maintained
The materialized path field is automatically computed and updated whenever a hierarchy edge is created or its parent changes. Application layer must never accept a client-supplied path value.