core PK: id 9 required 1 unique

Description

Structured notes written by peer mentors or coordinators about a specific contact, capturing observations, follow-up needs, and interaction context separate from formal activity registrations.

11
Attributes
5
Indexes
5
Validation Rules
10
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
contact_id uuid Foreign key to the contact this note belongs to
required
author_id uuid Foreign key to the user (peer mentor or coordinator) who wrote the note
required
organization_id uuid Tenant scoping — the organization this note belongs to
required
content text The body of the note, free-text written by the author
required
note_type enum Category of the note to support filtering and display
required
is_private boolean Whether the note is visible only to the author or also to coordinators
required
created_at datetime Timestamp when the note was created
required
updated_at datetime Timestamp of last edit
required
deleted_at datetime Soft delete timestamp; null means active
-
linked_activity_id uuid Optional reference to an activity this note relates to
-

Database Indexes

idx_contact_notes_contact_id
btree

Columns: contact_id

idx_contact_notes_author_id
btree

Columns: author_id

idx_contact_notes_organization_id
btree

Columns: organization_id

idx_contact_notes_contact_created
btree

Columns: contact_id, created_at

idx_contact_notes_deleted_at
btree

Columns: deleted_at

Validation Rules

content_not_empty error

Validation failed

content_max_length error

Validation failed

note_type_valid_enum error

Validation failed

contact_id_exists error

Validation failed

updated_at_after_created_at error

Validation failed

Business Rules

author_must_belong_to_same_org
on_create

The note author must be a member of the same organization as the contact being noted

private_notes_visible_to_author_only
always

Notes marked is_private=true are only returned when queried by the author; coordinators cannot see them

coordinator_can_view_non_private_notes
always

Coordinators can read all non-private notes for contacts in their local association

Enforced by: ContactService
soft_delete_only
on_delete

Notes are never hard-deleted; deleted_at is set instead to preserve audit trail

linked_activity_must_belong_to_same_contact
on_create

If linked_activity_id is set, the referenced activity must have the same contact_id

Enforced by: ContactService

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage