Validation
CSDB readers and writers validate both the file structure and relational model.
Structure
- The first section must be
--- csdb. - Unknown section headers are rejected.
- Human table sections must be grouped as schema then data.
- Machine sections must appear after all human sections.
- Table and database names must use letters, numbers,
_,-,., or$.
Metadata
formatmust beCSDB.versionmust be1.- The metadata
tableslist must match table section order. - Duplicate table names are rejected.
Schema
- Every table schema needs
nameand orderedcolumns. - Column names must be valid names.
- Primary key columns must exist and be listed in
required. - Required fields, defaults, unique constraints, foreign keys, and indexes must reference known columns.
- Unsupported runtime types are rejected unless represented as supported
customtypes.
Data
- CSV headers must match schema order exactly.
- Optional columns may contain null values unless they are part of the primary key.
- Required columns cannot be null.
- Primary key columns cannot be null.
- Values must decode according to their column type.
- Primary keys, unique constraints, and unique indexes cannot duplicate non-null values.
- Check constraints must evaluate truthy for each row.
- Foreign keys must reference existing target rows unless their source values are null.