Relative Case Link
Data Entity
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.
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
Columns: relative_id
idx_relative_case_links_contact_id
Columns: contact_id
idx_relative_case_links_org_id
Columns: organization_id
idx_relative_case_links_unique_active
Columns: relative_id, contact_id, organization_id, is_active
idx_relative_case_links_linked_by
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
Every relative_case_links row must belong to an organization. All queries must include organization_id to prevent cross-tenant data leakage.
no_duplicate_active_links
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.
soft_delete_only
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.
relative_contact_same_org
The relative and the contact being linked must both belong to the same organization_id. Cross-org linking is prohibited.
role_based_write_access
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
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.