On 2021-08-11T13:35:31 -0700
Rick Hillegas <rick.hille...@gmail.com> wrote:

> Triggers sound like the right tool for the job. I can't offer any more 
> specific advice. I don't understand why item_count and 
> item_location_count are hard-coded into the tables rather than being 
> constructed on the fly by queries.

Hello!

There might be a misunderstanding with regards to the data model.

Each row of items table describes a class of item, and indicates how
many of that class of item we have. Same goes for the item_locations
table; each row of the table indicates how many of each class of item
are in each storage location.

If, instead, the model was "each row of the items table describes
a single item", then yes, there'd be no item_count column and the
total would be calculated by counting the rows.

-- 
Mark Raynsford | https://www.io7m.com

Attachment: pgpgR756WcGgF.pgp
Description: OpenPGP digital signature

Reply via email to