Bỏ qua, đến nội dung

Database schema

ER Diagram

Chi tiết bảng

uiWidgets

Lưu định nghĩa widget. Mỗi record đại diện một thành phần UI (chart, table, form block...).

FieldTypeMô tả
uidstring (PK)UID duy nhất, sinh tự động
namestringTên widget, dùng để tham chiếu
optionsjsonCấu hình widget dạng JSON — schema tuỳ thuộc widget type

uiWidgetTreePath — Closure Table

Lưu mọi cặp ancestor-descendant trong cây widget. Đây là closure table pattern — cho phép truy vấn toàn bộ subtree hoặc ancestor chain trong một query.

FieldTypeMô tả
ancestorstring (FK)UID widget tổ tiên
descendantstring (FK)UID widget con cháu
depthintegerKhoảng cách: 0 = chính nó, 1 = con trực tiếp, 2 = cháu...
asyncbooleantrue = lazy load descendants (không load cùng parent)
typestringPhân loại quan hệ
sortintegerThứ tự sắp xếp giữa các siblings

Composite PK: (ancestor, descendant)

Cách hoạt động

Khi widget w3 là con của w1:

INSERT (w1, w3, 1)  -- w1 là ancestor trực tiếp
INSERT (w3, w3, 0)  -- self-reference

Khi thêm w4 là con của w3:

INSERT (w1, w4, 2)  -- w1 là ancestor cấp 2
INSERT (w3, w4, 1)  -- w3 là ancestor trực tiếp
INSERT (w4, w4, 0)  -- self-reference

Truy vấn toàn bộ subtree của w1:

sql
SELECT descendant FROM uiWidgetTreePath WHERE ancestor = 'w1'

queryService

Lưu query tái sử dụng cho widget.

FieldTypeMô tả
uidstring (PK)UID duy nhất
dataSourceKeystringKey của data source (main, tên external DS...)
sqltextCâu SQL — có thể chứa biến Liquid