Relative Role
Data Entity
Description
Configuration lookup table defining the structured role labels that can be assigned to relatives of contacts, indicating their relationship type (e.g., parent, sibling, caregiver, guardian). Org-scoped to allow terminology customization per organization while sharing a common role taxonomy.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key, UUID v4 | PKrequiredunique |
organization_id |
uuid |
FK to organizations. NULL indicates a platform-default role available to all orgs; non-NULL scopes the role to a specific organization. | - |
code |
string |
Machine-readable slug for the role (e.g., 'parent', 'sibling', 'guardian', 'caregiver', 'next_of_kin'). Used in API responses and offline sync; stable across terminology overrides. | required |
name |
string |
Display label for the role shown in the Relative Role Picker UI (e.g., 'Parent', 'Guardian', 'Sibling'). May be overridden per org via terminology system. | required |
description |
text |
Optional explanatory text describing when to use this role label. Shown as helper text in the picker widget. | - |
role_category |
enum |
Broad grouping for the role, used to organize the picker UI and filter roles contextually. | required |
is_active |
boolean |
Soft-disable flag. Inactive roles are hidden from the picker but preserved on existing relative records for historical integrity. | required |
sort_order |
integer |
Display ordering in the role picker. Lower values appear first. Platform-default roles use increments of 10 to allow org-specific roles to be inserted between them. | required |
is_platform_default |
boolean |
True for built-in roles seeded by the platform (not deletable by org admins). False for org-created custom roles. | required |
created_at |
datetime |
UTC timestamp of record creation. | required |
updated_at |
datetime |
UTC timestamp of last update, maintained by trigger. | required |
Database Indexes
idx_relative_roles_org_code
Columns: organization_id, code
idx_relative_roles_org_active
Columns: organization_id, is_active
idx_relative_roles_org_sort
Columns: organization_id, sort_order
idx_relative_roles_platform_defaults
Columns: is_platform_default, is_active
Validation Rules
code_format
error
Validation failed
name_non_empty
error
Validation failed
sort_order_non_negative
error
Validation failed
role_category_valid_enum
error
Validation failed
description_max_length
error
Validation failed
Business Rules
platform_defaults_not_deletable
Roles where is_platform_default=true cannot be deleted or deactivated by organization admins. Only Norse Global Admins may modify platform-default roles.
org_scoped_visibility
When fetching roles for a picker, return platform-default roles (organization_id IS NULL) UNION org-specific roles (organization_id = current org). Roles from other orgs are never exposed.
inactive_role_preserved_on_existing_relatives
Deactivating a role (is_active=false) hides it from new assignments but does not change role_id on existing relative records. Historical data integrity is preserved.
code_unique_per_org
The code field must be unique within the scope of an organization (including platform defaults that share the NULL org scope). Prevents ambiguous role lookups during offline sync.
offline_cache_sync
The full active role list (platform defaults + org-specific) is cached in the local Drift database at login and refreshed on each sync cycle. The mobile picker reads from the local cache, never directly from the API during offline operation.