Show HN: Denorm – Declarative derived columns (Postgres)

KenPainter1 pts0 comments

Denorm solves my own long-standing pain points with biz logic and the DB, providing a declarative DSL in which derived columns are part of the schema. Data moves along foreign keys: down from parent to child, aggregate from child to parent, and of course within rows. Can also generate parents and children along the foreign key.The README example: table us_states column state_code char(2) primary key column state_name varchar(20) column children_count integer count child_table table child_table column child_id serial primary key fk us_states references us_states pushes child_table column state_code is us_states.state_code column state_name sync us_states.state_name Denorm colocation of external values with derived values offers very high compression of logic definitions.It s a pay me now trade. The write is more expensive in exchange for simpler modeling, simpler reads and writes, simpler stack.The builder traps cycles, so we get termination. Builds are idempotent and additive, any-state to current. Ranged foreign keys are first class citizens (not just time series). Derived values are not subvertible. Race conditions and deadlocks eliminated (*except generating children can produce deadlocks the client must handle).If you already have Postgres installed, you can get something usable in 10-20 minutes following the README.

column us_states derived denorm foreign state_code

Related Articles