---
title: DBTable / TempTable — Validation Rules
aliases: [db-table, temp-table, tables, dbtable, temptable]
sources: [rcg-mobile-dev-agent/raw/006-contract-types-matrix.md, rcg-mobile-dev-agent/wiki/contracts/db-table.md]
last_updated: 2026-04-26
status: seed
---

# DBTable / TempTable — Validation Rules

DBTable contracts declare the local SQLite schema the mobile app uses; TempTable contracts declare transient per-session tables with the same shape. Both share one XSD (`tables.xsd`), one single-file validator, and a thin cross-contract validator that mostly checks that every column's `@domain` resolves to a declared Domain.

## What this contract represents

A DBTable (`.dbtable.xml`) defines a persistent table in the on-device SQLite database — rows survive across app launches. A TempTable (`.temptable.xml`) defines a table that is dropped and recreated per session, typically used for staging data imported from Salesforce. Both reference domains (from [[misc-contracts-validation|DomainRepository]]) for their column types.

## File shape

-   Extension: `.dbtable.xml` or `.temptable.xml`
-   Root element: `<DBTable>` or `<TempTable>` (shared XSD)
-   Columns sit under `<columns><column … /></columns>` with a `@domain` attribute naming a Domain.

## Validation rules

### Cross-cutting (every contract)

-   Contract names must be unique workspace-wide.
-   Files must be readable, well-formed XML.

### Must

-   Root element is `<DBTable>` or `<TempTable>`.
-   File name ends with `.dbtable.xml` (for DBTable) or `.temptable.xml` (for TempTable). Custom tables start with the customizing indicator in both the file name and the root `@name`.
-   Every `<columns/column @domain>` must resolve to a `<Domain @name>` entry in DomainRepository. A dangling domain reference is rejected.
-   DomainRepository must exist and be non-empty — the cross-contract check fails if there's no domain dictionary to resolve against.
-   Every `<Index>` must reference existing column names.
-   Column names, index names, and index-column names must all be unique within a table.

### Must not

-   A column cannot name a domain that DomainRepository hasn't declared.
-   Two columns in the same table cannot share a name; two indexes cannot share a name.

### Coerced (silently rewritten)

-   `xmlns="*.xsd"` on the root is stripped during pre-processing.
-   For Salesforce-backed TempTables, a missing mandatory `isdeleted` (`dombool`) column is warned — add it rather than relying on the warning.

## Reference

-   Internal schema reference: `rcg-mobile-dev-agent/wiki/contracts/db-table.md`.
-   Cross-repo raw source: `rcg-mobile-dev-agent/raw/006-contract-types-matrix.md`.

## See also

-   [[datasource]] — DataSources query DBTables and TempTables.
-   [[misc-contracts-validation]] — DomainRepository rules.
