Member Association
Data Entity
Description
Tracks the relationship between individual users (peer mentors and coordinators) and the local associations (lokallag) they belong to within an organization. Supports multi-membership (a user may belong to up to 5 local associations) and prevents double-reporting by scoping activity data to the correct local association context.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key | PKrequiredunique |
user_id |
uuid |
Foreign key to the user who is a member of the local association | required |
local_association_id |
uuid |
Foreign key to the local association (lokallag) the user belongs to | required |
role_in_association |
enum |
The user's role within this specific local association | required |
is_primary |
boolean |
Whether this is the user's primary local association for activity reporting and statistics aggregation | required |
status |
enum |
Current membership status in this local association | required |
joined_at |
datetime |
Timestamp when the user was associated with the local association | required |
left_at |
datetime |
Timestamp when the user left or was removed from the local association; null if still active | - |
invited_by_user_id |
uuid |
Foreign key to the admin or coordinator who created this membership association | - |
notes |
text |
Optional administrative notes about this membership (e.g. transfer reasons, special circumstances) | - |
created_at |
datetime |
Record creation timestamp | required |
updated_at |
datetime |
Record last update timestamp | required |
Database Indexes
idx_member_associations_user_id
Columns: user_id
idx_member_associations_local_association_id
Columns: local_association_id
idx_member_associations_user_local
Columns: user_id, local_association_id
idx_member_associations_status
Columns: status
idx_member_associations_primary
Columns: user_id, is_primary
Validation Rules
user_must_exist_and_be_active
error
Validation failed
local_association_must_exist
error
Validation failed
no_duplicate_active_membership
error
Validation failed
left_at_after_joined_at
error
Validation failed
inactive_cannot_be_primary
error
Validation failed
Business Rules
max_five_associations_per_user
A user may belong to at most 5 local associations within the same organization, reflecting NHF's requirement to handle members active in multiple lokallag
single_primary_association_per_user
Each user may have exactly one primary local association at any time. Setting a new association as primary must automatically demote the previously primary one
must_have_primary_if_any_active
If a user has at least one active association, exactly one must be flagged as primary for activity reporting attribution
association_scoped_to_organization
A user may only be associated with local associations that belong to the same organization as the user's membership. Cross-organization associations are not permitted
soft_delete_on_removal
Removing a user from a local association sets status to inactive and records left_at timestamp rather than deleting the row, preserving historical reporting integrity
audit_all_changes
All create, update, and status-change operations on member associations must be recorded in the audit log with actor user_id and timestamp