core PK: id 6 required 1 unique

Description

Organizational tier directly below the top-level organization, representing a national branch or federation. Groups regions and local associations for reporting hierarchies; NHF has 12 national associations, 9 regions, and 1,400 local associations.

12
Attributes
4
Indexes
7
Validation Rules
21
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Unique identifier for the national association, generated server-side via gen_random_uuid()
PKrequiredunique
organization_id uuid Foreign key referencing the top-level organization this national association belongs to (e.g., NHF, Blindeforbundet, HLF)
required
name string Full display name of the national association, e.g. 'NHF Trøndelag'. Must be unique within the parent organization.
required
short_name string Optional abbreviated identifier or code used in reports and compact UI contexts, e.g. 'NHF-TRØ'
-
description text Optional free-text description of the national association's geographic coverage, mandate, or other distinguishing context
-
is_active boolean Soft-delete and visibility flag. Inactive national associations are hidden from org tree navigation and coordinator scope resolution, but retained for historical reporting integrity.
required
activity_count integer Denormalized count of activities attributed to this national association level and all its child regions and local associations. Updated by database trigger on activity insert/delete.
-
region_count integer Denormalized count of direct child regions belonging to this national association. Maintained for efficient tree rendering without join queries.
-
local_association_count integer Denormalized count of all local associations under this national association across all child regions. Updated on region/local association create/delete.
-
metadata json Flexible key-value store for organization-specific configuration at the national association level, such as Bufdir reporting codes, grant identifiers, or legacy system IDs from Cornerstone/Consio.
-
created_at datetime Timestamp of record creation, set server-side via Supabase default. Used for audit trails and ordering in admin views.
required
updated_at datetime Timestamp of last record modification, auto-updated via Supabase trigger on any column change.
required

Database Indexes

idx_national_associations_organization_id
btree

Columns: organization_id

idx_national_associations_name_org
btree unique

Columns: organization_id, name

idx_national_associations_is_active
btree

Columns: organization_id, is_active

idx_national_associations_created_at
btree

Columns: created_at

Validation Rules

name_required_and_non_empty error

Validation failed

name_length_within_bounds error

Validation failed

organization_id_references_valid_record error

Validation failed

short_name_max_length error

Validation failed

metadata_valid_json error

Validation failed

activity_count_non_negative error

Validation failed

csv_import_row_validation error

Validation failed

Business Rules

unique_name_within_organization
on_create

A national association's name must be unique within its parent organization. Two national associations belonging to the same top-level organization (e.g., NHF) cannot share the same name. This prevents ambiguity in Bufdir reporting and coordinator scope resolution.

no_delete_with_child_regions
on_delete

A national association cannot be hard-deleted while it has one or more child regions. The admin must first reassign or delete all child regions and local associations before removing the national association. Cascade-delete is disabled to protect data integrity.

soft_delete_preserves_reporting_history
on_delete

National associations that are decommissioned must be soft-deleted (is_active = false) rather than hard-deleted. Historical activities attributed to their regions and local associations must remain intact for Bufdir audit and historical coordinator reports.

admin_only_write_access
always

Only users with global admin or organization admin roles are permitted to create, update, or delete national associations. Coordinator-level users have read-only access scoped to their affiliated national associations. Enforced via Supabase RLS policies.

organization_must_exist
on_create

Every national association must reference a valid, active top-level organization. A national association cannot be created for a non-existent or deactivated organization.

activity_attribution_rollup
always

When activities are registered at region or local association level, the activity count rolls up through the org hierarchy to the national association level for Bufdir reporting aggregation. The denormalized activity_count field is updated via a database trigger.

bufdir_scope_isolation
always

When generating Bufdir reports, activity data scoped to a national association must only include activities registered under its own regions and local associations. Cross-national-association data leakage is prevented by organization_id scoping in all queries.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage

Entity Relationships

organizations
outgoing many_to_one

National associations belong to the top-level organization entity

required
regions
incoming many_to_one

Regions aggregate under a national association within the hierarchy

optional