Subject Maintaining count with trigger, prevent updating on cascades
Author sqlsvr
I have two tables: blogs and blog posts. Blogs keep a count of blog posts and blog posts has a foreign key (cascade) to blogs. There is a trigger on blog posts that updates the count in blogs table.

Now, if a blog post is inserted/deleted, I want to update the blogs count. However, if a blog is deleted....it will cascade the delete on the blog posts table.

I'm assuming that this will cause the trigger to execute and update the blogs table unnecessarily? If so, is there anyway to stop it?