Skip to content

user_tags

M:N junction between users and tags.

  • ETL strategy: merge
  • PK: id

Columns

ColumnTypeDescription
idBIGINTPK.
id_tenantBIGINTFK → tenants.id.
id_userBIGINTFK → users.id.
id_tagBIGINTLogical FK to tags. Resolves to tags.id_origin when present, otherwise tags.id.

No created_at / deleted_at — this is a materialization of the current relationship state.

Patterns

sql
-- Users carrying the "VIP" tag
SELECT u.*
FROM lms.users u
JOIN lms.user_tags ut
    ON ut.id_tenant = u.id_tenant AND ut.id_user = u.id
JOIN lms.tags t
    ON t.id_tenant = ut.id_tenant
   AND (t.id = ut.id_tag OR t.id_origin = ut.id_tag)
WHERE t.title = 'VIP'
  AND u.deleted_at IS NULL
  AND t.deleted_at IS NULL;

OpenDB · Cademi LMS Data Warehouse