core PK: id 8 required 1 unique

Description

Records a peer mentor's enrollment in a training course, tracking enrollment status, completion, and the relationship between users and courses for certification purposes.

14
Attributes
5
Indexes
5
Validation Rules
11
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
user_id uuid Foreign key to users — the peer mentor enrolling in the course
required
course_id uuid Foreign key to courses — the course being enrolled in
required
status enum Current enrollment lifecycle state
required
enrolled_at datetime Timestamp when the enrollment was confirmed
-
completed_at datetime Timestamp when the user completed the course
-
cancelled_at datetime Timestamp when the enrollment was cancelled, if applicable
-
cancellation_reason text Optional free-text reason for cancellation
-
completion_score decimal Optional numeric score or grade achieved upon completion (0.0–100.0)
-
attended boolean Whether the user physically or virtually attended the course session
required
certificate_issued boolean Whether a certification record has been created as a result of this enrollment
required
notes text Coordinator or admin notes on this enrollment
-
created_at datetime Record creation timestamp
required
updated_at datetime Last modification timestamp
required

Database Indexes

idx_course_enrollments_user_id
btree

Columns: user_id

idx_course_enrollments_course_id
btree

Columns: course_id

idx_course_enrollments_user_course
btree unique

Columns: user_id, course_id

idx_course_enrollments_status
btree

Columns: status

idx_course_enrollments_completed_at
btree

Columns: completed_at

Validation Rules

valid_user_id error

Validation failed

valid_course_id error

Validation failed

completion_score_range error

Validation failed

completed_at_requires_enrolled_status_history error

Validation failed

status_transition_valid error

Validation failed

Business Rules

unique_active_enrollment
on_create

A user may not have more than one non-cancelled enrollment per course at any time

certificate_on_completion
on_update

When status transitions to 'completed' and attended=true, certificate-service is triggered to create a certifications record and set certificate_issued=true

no_revert_from_completed
on_update

An enrollment in 'completed' status cannot be moved back to any earlier status

cancellation_timestamp_required
on_update

When status is set to 'cancelled', cancelled_at must be populated automatically

waitlist_capacity_check
on_create

When a course reaches its max_participants, new enrollments are automatically set to 'waitlisted'

renewal_reminder_eligible
always

Completed enrollments with certificate_issued=true are eligible for renewal reminder evaluation via renewal-notification-service when the linked certification approaches expiry

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage