core PK: id 10 required 1 unique

Description

Junction entity linking a registered relative to a contact (case), enabling family members and next-of-kin to be associated with the primary case being supported by a peer mentor. Supports Barnekreftforeningen's relatives database where families around a child with cancer are tracked as distinct contacts linked to the same case.

11
Attributes
5
Indexes
4
Validation Rules
10
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
relative_id uuid Foreign key referencing the relative record being linked
required
contact_id uuid Foreign key referencing the contact (case) this relative is linked to
required
organization_id uuid Tenant scoping — the organization this link belongs to
required
relationship_type enum Nature of the relationship between the relative and the contact
required
is_primary_contact boolean Whether this relative is the primary point of contact for the case
required
notes text Free-text notes about this relationship or link context
-
linked_by_user_id uuid User (peer mentor or coordinator) who created this link
required
linked_at datetime Timestamp when the link was created
required
updated_at datetime Timestamp of last modification
required
is_active boolean Soft-delete flag; false means the link has been removed without deleting the record
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_organization_id
btree

Columns: organization_id

idx_relative_case_links_relative_contact
btree unique

Columns: relative_id, contact_id

idx_relative_case_links_contact_active
btree

Columns: contact_id, is_active

Validation Rules

relative_exists_in_org error

Validation failed

contact_exists_in_org error

Validation failed

relationship_type_required error

Validation failed

linked_by_user_in_org error

Validation failed

Business Rules

unique_relative_contact_pair
on_create

A relative can only be linked to the same contact once (enforced by unique index). Re-linking after soft-delete reactivates the existing record rather than inserting a duplicate.

Enforced by: CaseLinkService
tenant_scoped_link
on_create

Both relative_id and contact_id must belong to the same organization_id as the link record. Cross-tenant linking is forbidden.

Enforced by: CaseLinkService
single_primary_contact_per_case
on_create|on_update

At most one relative per contact can have is_primary_contact = true. Setting a new primary contact automatically clears the flag on any existing primary relative for that contact.

Enforced by: CaseLinkService
relatives_database_module_required
on_create

Relative case links can only be created when the relatives-database module is enabled for the organization.

Enforced by: CaseLinkService

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage