core PK: id 6 required 1 unique

Description

An intermediate organizational tier between the national organization and local associations. Represents one of the 9 regional groupings used primarily by NHF. Regions aggregate local association data for regional reporting and coordinator oversight.

6
Attributes
3
Indexes
4
Validation Rules
16
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Surrogate primary key for the region record
PKrequiredunique
organization_id uuid Foreign key referencing the parent organization that owns this region. All regions are scoped to exactly one organization.
required
name string Human-readable display name for the region (e.g., 'Region Vest', 'Region Nord'). Used in reports, coordinator dashboards, and hierarchy navigation.
required
code string Short alphanumeric identifier for the region used in Bufdir reporting, exports, and API references (e.g., 'VEST', 'NORD'). Must be unique within the parent organization.
required
created_at datetime Timestamp when the region record was created. Set automatically on insert and never updated.
required
updated_at datetime Timestamp of the last modification to the region record. Updated automatically on any field change.
required

Database Indexes

idx_region_organization_id
btree

Columns: organization_id

idx_region_organization_code
btree unique

Columns: organization_id, code

idx_region_name
btree

Columns: name

Validation Rules

name_not_empty error

Validation failed

code_format_valid error

Validation failed

organization_id_exists error

Validation failed

id_is_valid_uuid error

Validation failed

Business Rules

region_belongs_to_one_organization
on_create

Each region must be associated with exactly one organization and cannot be reassigned to a different organization after creation. This preserves the integrity of the multi-tenancy hierarchy.

region_code_unique_within_organization
on_create

The region code must be unique within the scope of its parent organization. Two different organizations may use the same code, but a single organization cannot have two regions sharing a code.

region_deletion_blocked_with_associations
on_delete

A region cannot be deleted if it has any local associations still assigned to it. Local associations must be reassigned or deleted first to prevent orphaned hierarchy nodes.

region_data_scoped_to_tenant
always

All reads and writes to region records must be scoped to the authenticated user's organization_id, extracted from the JWT tenant context. Cross-organization region access is forbidden.

region_hierarchy_depth_enforced
on_create

Regions exist only at the second tier of the hierarchy (organization → region → local_association). They cannot be nested inside other regions or directly under a local association.

bufdir_reporting_aggregates_through_region
always

When generating Bufdir reports, activity data must be rolled up from local_association → region → organization. Region records are required for correct hierarchical aggregation even when the organization does not actively use regional structure.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage

Entity Relationships

organization
incoming one_to_many

An organization has multiple regional groupings that aggregate local associations

required
local_association
outgoing one_to_many

A region contains multiple local associations (chapters/branches)

optional