Appearance
lesson_ratings
Like / dislike ratings on lessons by learners.
- ETL strategy:
merge - PK:
id
Columns
| Column | Type | Description |
|---|---|---|
id | BIGINT | PK. |
id_tenant | BIGINT | FK → tenants.id. |
id_product | BIGINT | FK → products.id. |
id_lesson | BIGINT | FK → lessons.id. |
id_user | BIGINT | FK → users.id. |
vote | SMALLINT | Like / dislike. Enum — see below. |
created_at | TIMESTAMPTZ |
No
deleted_at. To "remove" a rating, the system deletes the row (no soft-delete). Account for that when auditing.
Enum · vote
| Value | Meaning |
|---|---|
1 | Like (positive vote). |
-1 | Dislike (negative vote). |
Patterns
sql
-- Best-rated lessons
SELECT id_lesson,
count(*) AS total,
sum((vote = 1)::int) AS likes,
sum((vote = -1)::int) AS dislikes,
round(avg(vote)::numeric, 3) AS score
FROM lms.lesson_ratings
GROUP BY id_lesson
HAVING count(*) >= 10
ORDER BY score DESC, total DESC;A pre-aggregated view exists:
metrics.lesson_rating_aggregates.