core PK: id 9 required 1 unique

Description

Records caregiver and next-of-kin relationships for contacts (people receiving peer mentor support). Stores contact details and relationship metadata for emergency or coordination purposes, scoped to the contact's organization for multi-tenancy isolation.

13
Attributes
3
Indexes
5
Validation Rules
14
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key, generated on creation
PKrequiredunique
contact_id uuid Foreign key referencing the contact this caregiver is associated with
required
first_name string Caregiver's first name
required
last_name string Caregiver's last name
required
relationship enum The caregiver's relationship to the contact
required
phone_number string Caregiver's phone number (E.164 format preferred)
-
email string Caregiver's email address
-
address text Caregiver's physical address (free text to accommodate varying formats)
-
is_primary_caregiver boolean Whether this is the primary/emergency contact for the contact person. At most one caregiver per contact may be primary.
required
notes text Free-text notes about availability, preferences, or context for this caregiver
-
created_by uuid User ID of the peer mentor or coordinator who created this record
required
created_at datetime Timestamp when the record was created (UTC)
required
updated_at datetime Timestamp when the record was last modified (UTC)
required

Database Indexes

idx_contact_caregivers_contact_id
btree

Columns: contact_id

idx_contact_caregivers_primary_per_contact
btree

Columns: contact_id, is_primary_caregiver

idx_contact_caregivers_created_by
btree

Columns: created_by

Validation Rules

valid_email_format error

Validation failed

phone_number_format error

Validation failed

name_not_blank error

Validation failed

relationship_enum_valid error

Validation failed

contact_exists error

Validation failed

Business Rules

single_primary_caregiver_per_contact
on_create

A contact may have at most one primary caregiver (is_primary_caregiver = true). When a new caregiver is set as primary, any existing primary caregiver for that contact must be demoted to non-primary atomically.

at_least_one_contact_method
on_create

A caregiver record must have at least one of: phone_number or email populated. A caregiver with no way to be contacted is not useful for emergency coordination.

org_scoped_access
always

A user may only read or write caregiver records whose parent contact belongs to the same organization as the user. Cross-organization access is forbidden.

cascade_delete_with_contact
on_delete

When a contact record is deleted, all associated caregiver records are deleted. Orphaned caregiver records must not exist.

Enforced by: Caregivers Repository

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage