Select functional table types and characteristics

Completed

Functional table types are application patterns rather than AL keywords. You implement each pattern by combining fields, keys, relationships, field groups, triggers, and code that match the table's responsibility.

Match characteristics to table purpose

Setup tables commonly use a blank primary key and expose one record per company. Master tables use a stable business number, a descriptive name, a blocked state, and number-series integration. Document headers use a document number and status, while document lines use a compound key such as document number and line number.

Ledger-style entry tables use a sequential entry number and secondary keys for common history views. They don't reuse the editable document as history. Register tables use a register number and entry-number range so users can trace one processing operation.

Define keys and relationships intentionally

The primary key expresses record identity. Add secondary keys only for common filters, sorting, or calculation paths. Excess keys increase write cost, so don't add a key for every page column.

Use TableRelation to validate references and support lookups. Use a DropDown field group on master tables to display the number and description together. Set DataClassification on every field according to the data it stores.

field(2; "Equipment No."; Code[20])
{
    Caption = 'Equipment No.';
    TableRelation = "Inspection Equipment"."No." where(Blocked = const(false));
    DataClassification = CustomerContent;
}

The filter prevents new documents from selecting blocked equipment. Table logic must still test the blocked state when code assigns a value in a way that bypasses UI lookup behavior.

Keep trigger behavior predictable

Use table triggers for invariants that apply to every caller. An OnInsert trigger can assign a number. A field OnValidate trigger can copy a default description. An OnDelete trigger can reject deletion when documents or entries reference a master record.

Avoid multi-table processing in field triggers. Hidden side effects make validation order difficult to understand and can create partial data. Move release, posting, or processing operations to a codeunit with a named procedure and explicit preconditions.

For more information, see Table object, Table keys, and Field groups.