Hacker News new | ask | show | jobs
by MaxBarraclough 1239 days ago
> Discoverability can be quite lacking.

A richer type system would help there, but to my knowledge this isn't offered by any major relational DBMS.

1 comments

https://www.postgresql.org/docs/current/sql-createtype.html

Postgres allows you to define custom types at least; making some enums or composites might give you some measure of sanity..?

Thanks.

The Ada programming language is known for encouraging use of specialised numerical types, where the range can be expressed and automatically checked at runtime, and the compiler can help protect against nonsensical comparisons or arithmetic. At a glance I think Postgres range types offer something similar. Presumably strong typing could also be achieved with Postgres composite types (of just one member).

It would be useful to have such checks so that a nonsensical comparison like WHERE person1.height = person2.net_worth would result in an error. Presumably it could also be helpful for autocompletion.