I have 2 tables, Organisation and State(where it is). Each Organisation has a state. I would now like to implement a Integer column for the table State which keeps tracks of how many organisations are in it. Kinda like whenever a new organisation is inserted into Organisations table, update integer column in corresponding State table where org.state_id = state_id.
Is this possible using triggers?
I agree with Glenn’s answer that, all things being equal, on-demand is a better solution, but the answer is that, yes, it can be done with a trigger. Very easily.
Demo