Course Enrollment
Data Entity
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.
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
Columns: user_id
idx_course_enrollments_course_id
Columns: course_id
idx_course_enrollments_user_course
Columns: user_id, course_id
idx_course_enrollments_status
Columns: status
idx_course_enrollments_completed_at
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
A user may not have more than one non-cancelled enrollment per course at any time
certificate_on_completion
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
An enrollment in 'completed' status cannot be moved back to any earlier status
cancellation_timestamp_required
When status is set to 'cancelled', cancelled_at must be populated automatically
waitlist_capacity_check
When a course reaches its max_participants, new enrollments are automatically set to 'waitlisted'
renewal_reminder_eligible
Completed enrollments with certificate_issued=true are eligible for renewal reminder evaluation via renewal-notification-service when the linked certification approaches expiry