core PK: id 7 required 1 unique

Description

Represents the local organizational units (lokallag) within a parent organization's hierarchy. Each local association is the primary operational scope for peer mentors and coordinators, determining activity reporting boundaries, coordinator oversight scope, expense approval routing, and Bufdir report aggregation. NHF alone has 1,400 local associations across 12 national associations and 9 regions.

17
Attributes
7
Indexes
7
Validation Rules
28
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Unique identifier for the local association
PKrequiredunique
organization_id uuid Foreign key to the parent organization this local association belongs to
required
parent_association_id uuid Self-referencing foreign key for hierarchical nesting (e.g., regional association containing local associations). Null for top-level associations.
-
name string Display name of the local association (e.g., 'NHF Oslo Lokallag')
required
short_name string Abbreviated name for compact UI display and reports
-
external_id string External system identifier for integration with member registries, Dynamics portals, or legacy systems
-
association_type enum Classification of the association level within the organizational hierarchy
required
status enum Operational status of the local association
required
contact_email string Primary contact email for the local association
-
contact_phone string Primary contact phone number for the local association
-
address text Physical address or meeting location of the local association
-
region string Geographic region label for grouping and filtering (e.g., 'Vestland', 'Trøndelag')
-
municipality_code string Norwegian municipality code (kommunenummer) for geographic mapping and Bufdir reporting
-
member_count integer Cached count of active members in this association for dashboard display
-
metadata json Extensible JSON field for organization-specific configuration (custom terminology overrides, reporting preferences, feature flags)
-
created_at datetime Timestamp when the association record was created
required
updated_at datetime Timestamp of last update to the association record
required

Database Indexes

idx_local_associations_organization
btree

Columns: organization_id

idx_local_associations_parent
btree

Columns: parent_association_id

idx_local_associations_org_name
btree unique

Columns: organization_id, name

idx_local_associations_status
btree

Columns: organization_id, status

idx_local_associations_type
btree

Columns: organization_id, association_type

idx_local_associations_external_id
btree unique

Columns: organization_id, external_id

idx_local_associations_region
btree

Columns: organization_id, region

Validation Rules

name_not_blank error

Validation failed

valid_organization_reference error

Validation failed

valid_parent_reference error

Validation failed

valid_email_format error

Validation failed

valid_municipality_code warning

Validation failed

status_transition_validity error

Validation failed

external_id_unique_per_org error

Validation failed

Business Rules

unique_name_within_organization
on_create

Each local association name must be unique within its parent organization to prevent confusion in coordinator scoping and Bufdir reporting

parent_must_belong_to_same_organization
on_create

If parent_association_id is set, the parent association must belong to the same organization_id to maintain tenant isolation

no_circular_hierarchy
on_update

An association cannot be its own ancestor in the hierarchy tree. The closure table must be checked before any parent reassignment to prevent cycles

dissolution_requires_member_reassignment
on_update

A local association cannot be set to 'dissolved' or 'merged' status while it still has active user memberships in user_local_associations. Members must be reassigned first to prevent orphaned reporting data

coordinator_scope_boundary
always

Coordinators can only view and manage peer mentors, activities, and expenses within their assigned local association(s). This association boundary is the primary access control dimension for coordinator-level operations

multi_membership_duplicate_prevention
always

Users belonging to multiple local associations (up to 5 for NHF) must have one designated primary association to prevent double-counting in Bufdir reports and activity statistics

inactive_association_blocks_new_activities
always

No new activities, events, or expense claims can be created against an inactive, merged, or dissolved local association

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage

Components Managing This Entity

service Role Guard Service ["mobile"] service Role Guard Service ["mobile","backend"] service Activity Service ["mobile"] service Activity Service ["mobile"] service Activity Service ["mobile"] service Proxy Registration Service ["mobile"] service Proxy Registration Service ["mobile","backend"] service Bulk Processing Service ["mobile"] service Bulk Processing Service ["backend"] service Bulk Validation Service ["backend"] service Event Service ["backend"] service Event Service ["mobile"] service Expense Service ["mobile"] service Expense Service ["mobile"] service Team Stats Service ["mobile","backend"] service Team Stats Service ["backend","mobile"] data Report Store ["backend"] data Report Store ["backend"] service KPI Aggregation Service ["backend"] service KPI Aggregation Service ["backend"] service Activity Feed Service ["backend"] service Activity Feed Service ["backend"] data User Repository ["backend"] data User Repository ["backend"] service User Service ["backend"] service User Service ["backend"] ui User Detail Page ["frontend"] ui User Detail Page ["frontend"] service Activity Approval Service ["backend"] service Activity Approval Service ["backend"] data Report Store ["backend"] data Report Store ["backend"] service Report Generation Service ["backend"] service Report Generation Service ["backend"] ui Reports Dashboard Page ["frontend"] ui Reports Dashboard Page ["frontend"] service Bufdir Export Service ["backend"] service Bufdir Export Service ["backend"] service Organization Service ["backend"] service Organization Service ["backend"] data Hierarchy Store ["backend"] data Hierarchy Store ["backend"] infrastructure Hierarchy Migration Seeder ["backend"] service Hierarchy Scope Resolver ["backend"] service Hierarchy Service ["backend"] service Hierarchy Service ["backend"] ui Hierarchy Management Page ["frontend"] ui Hierarchy Management Page ["frontend"] data Association Membership Store ["backend"] service Association Service ["backend"] service Association Service ["backend"] ui Member Association Page ["frontend"] ui Member Association Page ["frontend"]