Schema design Required
Choose exact types
Store each value in the type that means it. Money is an exact number, time is a time with a zone, and true or false is a boolean.
How to do it
Store money as integer cents or numeric, never as a floating point float, real or double. Store moments in time as timestamptz in PostgreSQL, or as UTC in other databases, and convert to local time only for display. timestamptz stores the moment in UTC and does not keep the original zone, so store the zone name in its own column when it matters. Use date, boolean and JSON types instead of text, and jsonb rather than json in PostgreSQL. In SQLite, declare tables STRICT so it refuses values of the wrong type. In MySQL, use the utf8mb4 character set, because the old utf8 cannot store emoji.
Example
-- Bad: 0.1 + 0.2 is not 0.3 in floating point, and the zone is lost
price float, ordered_at timestamp
-- Good
price_cents bigint NOT NULL, ordered_at timestamptz NOT NULL
-- Check in PostgreSQL: expect no rows
SELECT table_name, column_name, data_type FROM information_schema.columns
WHERE table_schema = 'public'
AND data_type IN ('real', 'double precision', 'timestamp without time zone');
How to check
A query over the catalog lists every float column and every timestamp without a zone. The list is empty, or each entry is documented as not money and stored as UTC.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/schema-design/exact-types.