core PK: id 9 required 1 unique

Description

Junction entity recording explicit associations between registered relatives and contact cases within an organization. Enables Barnekreftforeningen and similar orgs to model family networks around a contact, linking relatives (e.g. parents, siblings) to the primary contact record they support.

12
Attributes
5
Indexes
5
Validation Rules
8
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
relative_id uuid Foreign key to relatives table — the relative being linked
required
contact_id uuid Foreign key to contacts table — the case/contact this relative is linked to
required
organization_id uuid Owning organization for row-level isolation in multi-tenant setup
required
linked_by_user_id uuid User who created this link (peer mentor or coordinator)
required
link_type enum Classification of why this relative is linked to the case
required
notes text Optional free-text notes explaining the context of this case link
-
is_active boolean Soft-delete flag; false means the link has been removed but is preserved for audit history
required
deactivated_at datetime Timestamp when the link was soft-deleted; null if still active
-
deactivated_by_user_id uuid User who deactivated the link; null if still active
-
created_at datetime UTC timestamp of link creation
required
updated_at datetime UTC timestamp of last update
required

Database Indexes

idx_relative_case_links_relative_id
btree

Columns: relative_id

idx_relative_case_links_contact_id
btree

Columns: contact_id

idx_relative_case_links_org_id
btree

Columns: organization_id

idx_relative_case_links_unique_active
btree

Columns: relative_id, contact_id, organization_id, is_active

idx_relative_case_links_linked_by
btree

Columns: linked_by_user_id

Validation Rules

relative_id_required error

Validation failed

contact_id_required error

Validation failed

link_type_enum_valid error

Validation failed

notes_max_length error

Validation failed

deactivation_fields_consistency error

Validation failed

Business Rules

org_scoped_isolation
always

Every relative_case_links row must belong to an organization. All queries must include organization_id to prevent cross-tenant data leakage.

Enforced by: Case Link Service
no_duplicate_active_links
on_create

A relative cannot be linked to the same contact more than once within the same organization while is_active = true. Attempting to create a duplicate active link returns an error.

Enforced by: Case Link Service
soft_delete_only
on_delete

Links are never hard-deleted. Deactivation sets is_active = false and records deactivated_at and deactivated_by_user_id. This preserves historical family network data for Bufdir audit trails.

Enforced by: Case Link Service
relative_contact_same_org
on_create

The relative and the contact being linked must both belong to the same organization_id. Cross-org linking is prohibited.

Enforced by: Case Link Service
role_based_write_access
on_create|on_update|on_delete

Only Peer Mentors and Coordinators assigned to the same organization may create or deactivate case links. Global Admins require explicit support access grant.

offline_optimistic_mutation
on_create|on_delete

Case link creation and deactivation are queued in the Drift mutation outbox when offline. Synced to the backend when connectivity is restored. Conflict resolution: server wins on concurrent deactivations.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage