core PK: id 9 required 1 unique

Description

Junction entity that links users to one or more local chapters/organizations they belong to, supporting multi-association membership (e.g. NHF members who belong to up to 5 local chapters). Each row represents a single user-to-organization membership with role context and activity attribution rules, preventing double-counting in Bufdir reports.

12
Attributes
5
Indexes
7
Validation Rules
18
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key identifier for the member association record
PKrequiredunique
user_id uuid Foreign key reference to the user holding this membership
required
organization_id uuid Foreign key reference to the local chapter/organization the user is associated with
required
role_id uuid Foreign key reference to the role held within this specific organization (a user can have different roles in different chapters)
required
is_primary boolean Whether this is the user's primary association used as default for activity attribution and Bufdir reporting when no chapter is explicitly selected
required
status enum Current state of the membership
required
joined_at datetime Timestamp when the user joined this organization
required
left_at datetime Timestamp when the user left this organization (null if still active)
-
invited_by uuid User ID of the coordinator or org admin who created this association
-
metadata json Org-specific extension data (e.g. local member number, chapter-specific labels, regional codes)
-
created_at datetime Record creation timestamp
required
updated_at datetime Last modification timestamp
required

Database Indexes

idx_member_associations_user_org
btree unique

Columns: user_id, organization_id

idx_member_associations_user
btree

Columns: user_id

idx_member_associations_org
btree

Columns: organization_id

idx_member_associations_status
btree

Columns: status

idx_member_associations_user_primary
btree

Columns: user_id, is_primary

Validation Rules

unique_user_organization_pair error

Validation failed

valid_user_reference error

Validation failed

valid_organization_reference error

Validation failed

valid_role_reference error

Validation failed

status_enum_check error

Validation failed

left_at_after_joined_at error

Validation failed

left_at_requires_inactive_status error

Validation failed

Business Rules

max_five_associations_per_user
on_create

A user may belong to at most 5 local chapters concurrently (NHF constraint from ยง3.2)

exactly_one_primary_association
always

Each user with at least one active association must have exactly one association flagged is_primary=true; setting a new primary unsets the previous one

prevent_duplicate_activity_attribution
always

Activities registered by a user with multi-chapter membership must be attributed to exactly one organization to prevent double-counting in Bufdir reports

role_scoped_to_organization
on_create

The role_id must be valid within the context of the linked organization_id; a user can be a Coordinator in chapter A and a Peer Mentor in chapter B

soft_delete_preserves_history
on_delete

Removing an association sets status=inactive and populates left_at rather than hard-deleting, preserving historical activity attribution

audit_membership_changes
always

All create/update/delete operations on member associations are logged to the audit trail per organization

tenant_isolation
always

Org Admins may only manage associations involving their own organization; Global Admins require time-bounded support access flag

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage