/tools

Data-contract builder

Define ownership, business grain and field expectations. Review check coverage and prepare PostgreSQL validation queries. Everything stays in this browser; no database is connected and no data has been checked.

Save each form before exporting. Selecting or saving another item restores other forms to saved values. Undo keeps 20 revisions. Reload clears this work unless you export JSON.

Open contract JSON

Open a saved pg-data-contract-v1 document up to 1 MB. Files are read locally. Undo restores the previous collection.

Scope, SQL semantics and limits

Ownership, version, review state and business grain are declarations. “Reviewed” does not certify any data. The schema probe lists declared and actual types and nullability for the selected dataset and its referenced parents; it does not infer domain/type equivalence. Run it first and resolve missing relations, columns and incompatible types before value queries. Value checks do not enforce declared varchar length, numeric precision, time zone, collation, physical constraints or business grain prose.

Validation exports contain SELECT statements only. Counts reflect rows visible to the executing role, including row-level security. Uniqueness counts all rows belonging to duplicate groups, not just excess rows. Forbid-NULL uniqueness counts NULL-containing rows once and duplicates among fully non-NULL keys. Relationship MATCH SIMPLE and MATCH FULL NULL rules are explicit; parent uniqueness covers only non-NULL keys. Required checks test whether the overall value is SQL NULL, including unknown/composite type hints.

Accepted values and bounds use escaped literals and fixed comparison types. Numeric literals remain strings and compare as unconstrained numeric; text compares as text, avoiding typmod rounding/truncation. Boolean literals use true/false, UUIDs use canonical hyphens, bytea uses hex beginning with \x and jsonb uses JSON syntax. PostgreSQL must validate date/time formats, numeric ranges, casts, collations and actual type support. Range bound ordering is checked locally only for finite numeric literals. Unknown/custom types and custom specifications require manual checks. Raw custom text is never emitted as SQL syntax. There is no sample-data validator, SQL execution, constraint creation or migration.

Deleting a dataset/field retains referencing expectations so missing references can be repaired rather than silently weakening the contract. JSON, CSV and documentation retain all rules, including disabled/manual rules. SQL labels coverage omissions. Selected SQL is blocked by selected definition errors and referenced parent metadata errors; unrelated draft datasets do not block it.

Limits: 1 MB, 30 datasets, 800 fields total, 100 fields and 100 rules per dataset, 16 columns per key/relationship, 200 accepted values per rule and 1,000 characters per value/bound. Numeric exponent limit ±10,000. Names assume PostgreSQL’s standard 63-byte limit. Undo keeps 20 revisions in memory. Nothing is stored or transmitted.

PostgreSQL comparisons and NULLs · PostgreSQL constraints