Column Types and Business Rules
A column type controls representable values. A domain constraint can restrict values further according to what the application means.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a quantity
An integer column can represent minus one. A quantity with a rule of at least zero needs a separate condition. Structural and domain validation distinguish these checks at a service boundary too.
Think about shared writes
Apply a durable database rule when several writers need to preserve it. Add tests that cover zero, a positive value, and minus one. Boundary cases verify the precise limits.[1][2]
Use a valid type with an invalid business value
An integer seat count can store minus one as a valid integer. A constraint requiring nonnegative seats would reject it. Separating type and domain rule lets the database enforce both where appropriate. See structural and domain validation.
Input Integer type Nonnegative rule
0 valid pass
-1 valid fail
null type compatible as absence needs a separate presence policy
Keep cross-row and row-local rules distinct
A row check can compare start and end in one row. Uniqueness across rows is a different constraint. Test boundary values and multi-column rules at the actual database boundary.