Appearance
users
Platform learners.
- ETL strategy:
merge - PK:
id
Columns
| Column | Type | Description |
|---|---|---|
id | BIGINT | PK. |
id_tenant | BIGINT | FK → tenants.id. Which instance the learner belongs to. |
is_free | BOOLEAN | Learner on the free tier. |
name | TEXT | Full name. |
email | TEXT | Email (not unique — the same address may exist in different tenants). |
phone | VARCHAR(50) | Mobile phone. |
document | VARCHAR(50) | National document (CPF/CNPJ or equivalent). |
score | INTEGER | Cumulative gamification score. |
started_at | TIMESTAMPTZ | When the learner first started using the platform. |
last_access_at | TIMESTAMPTZ | Most recent access. |
created_at | TIMESTAMPTZ | Account creation. |
deleted_at | TIMESTAMPTZ | Soft delete. |
Relationships
- Parent:
tenantsviaid_tenant. - Children:
user_logs,user_lesson_progress,user_product_progress,exam_results,user_certificates,lesson_ratings,scores,user_tracks,user_tags.
Patterns
sql
-- Active learners (not deleted, with active tenant)
SELECT u.*
FROM lms.users u
JOIN lms.tenants t ON t.id = u.id_tenant AND t.deleted_at IS NULL
WHERE u.deleted_at IS NULL;
-- Active paying learners
SELECT count(*) FROM lms.users
WHERE deleted_at IS NULL AND is_free = FALSE;