<aside> <img src="/icons/checklist_green.svg" alt="/icons/checklist_green.svg" width="40px" />
</aside>
Table categories [note: 'Bảng lưu trữ danh mục khóa học (CNTT, Kinh doanh, Ngôn ngữ, ...)']
{
id uuid [pk, increment] // Khóa chính, tự tăng
parent_id uuid [null, ref: > categories.id]
title varchar [not null, note: 'Tên danh mục']
slug varchar [unique, not null, note: 'Đường dẫn thân thiện (URL)']
// short_description text [not null, note: 'Mô tả ngắn cho danh mục']
order int [default: 0]
status product_status [default: 'draft']
created_at timestamp [default: `now()`, note: 'Thời điểm tạo']
updated_at timestamp [default: `now()`, note: 'Thời điểm cập nhật lần cuối']
deleted_at timestamp [null, note: 'Thời điểm xóa (soft-delete)']
}
| Trường | Kiểu dữ liệu | Ràng buộc | Mô tả |
|---|---|---|---|
id |
UUID |
PRIMARY KEY | Khóa chính, tự sinh |
parent_id |
UUID |
REFERENCES categories(id), NULLABLE |
Tham chiếu đến danh mục cha (nếu có) |
title |
VARCHAR |
NOT NULL | Tên danh mục (1–150 ký tự) |
slug |
VARCHAR |
UNIQUE, NOT NULL | Đường dẫn thân thiện (URL) |
short_description |
TEXT |
NOT NULL | Mô tả ngắn cho danh mục |
order |
INT |
NOT NULL, DEFAULT 0 |
Thứ tự hiển thị trong giao diện |
status |
ENUM |
NOT NULL, DEFAULT 'draft' |
Trạng thái (draft |
created_at |
TIMESTAMP |
NOT NULL, DEFAULT NOW() |
Thời điểm bản ghi được tạo |
updated_at |
TIMESTAMP |
NOT NULL, DEFAULT NOW() |
Thời điểm bản ghi được cập nhật lần cuối |
deleted_at |
TIMESTAMP |
NULLABLE | Thời điểm xóa logic (soft-delete) |
parent_id có thể NULL hoặc trỏ tới một id tồn tại trong categories chưa bị soft-deleteslug phải là unique trên bảng categoriestitle theo chuẩn:
--{Date.now().toString(36)}draft, published, archivedpublished , category sẽ được hiển thị cho user cuốiorder là số nguyên ≥ 0parent_id giống nhau), không trùng order; có thể reindex tự động.