What you’re describing is basically an incremental materialized view, a denormalized table that stays in sync with its source data.
There are tools and databases built around this idea, like Materialize and pg_imv.