On Thu, 26 Feb 2015 15:31:56 +0000
"Martin J. Evans" <boh...@ntlworld.com> wrote:

> I would actually suggest you don't use a trigger for this and also 
> that you don't store the count of people in a house in a column in 
> the house table. You can always calculate how many people there are 
> in a house but if you use triggers or some other mechanism to keep 
> the count you run the risk of the count not actually agreeing with 
> the rows with that house id. In other words, I think this is 
> generally bad design.

You could get a one-step summary using a view that does a select
with count(1) as "people" from a join of houses and people, grouped
by the house. That leaves the houses and people separate and still
gives you one-stop shopping for the houses with accurate counts.

-- 
Steven Lembark                                             3646 Flora Pl
Workhorse Computing                                   St Louis, MO 63110
lemb...@wrkhors.com                                      +1 888 359 3508

Reply via email to