Table
The definition of one data entity, its columns and its indexes, stored through a pluggable database driver.
A Table defines one data entity: its columns, the indexes used to look rows up, and which database driver stores it. Unlike a program, a Table carries no workflow, no events and no UI, its schema is the whole contract. Every read and write in a Xuda app eventually points at a Table through a Get Data, Set Data, Batch or Component datasource.
Properties
The table sits under studio_meta.parentId: "database" (or a folder nested under it).
tableFields
A table named "ORD - Orders" prefixes every column: ORD_Id, ORD_Total, ORD_Status. It keeps field names unambiguous once several tables sit in the same expression, and it is the convention every existing table in a project follows.
tableIndexes
A table needs at least one field before it can carry an index. An index itself is only mandatory for tables on a non-native database driver, the platform's own engine (@xuda.io/xuda-dbs-plugin-xuda) accepts a table with zero indexes, though in practice every table that a Component or a set_data program can bind to a single record needs a unique <TBL>_Id index to do it.
Using a table
- Read or write a row: a Get Data, Set Data or Batch program's
progDataSource.dataSourceTableIdnames this table's_id. - Bind a Component directly: the same
dataSourceTableId/dataSourceIndexIdpair, embedded on the Component instead of a separate program. - From a script:
xu.dbs_create,xu.dbs_read,xu.dbs_update,xu.dbs_delete, called with the table's_id, never its name.
Worked example
Model the columns
One table per entity, one 3-letter prefix per table: STU_Student_Id, STU_Full_Name.
Add a unique index on the id
Give every table a unique index on its <TBL>_Id field. Components that bind a single record by key, and set_data programs in update or delete mode, resolve the target row through this index.
Point a datasource at it
A Get Data or Set Data program's dataSourceTableId names this table's _id; dataSourceIndexId names one of the ids in tableIndexes.
Under Database in the Studio tree, add a table, then add rows to its Fields grid (id, type, mandatory) and its Indexes grid (name, keys, unique). The Data tab on the same node shows and edits rows directly.
A table has no .xu source form, xuda-cli projects declare it as a .table.json5 file instead (this is that file, shown as JSON).