fixes #6216 - foreign key errors such as deleting a subnet that is associated with a host group and others

no, don't worry, I'll link and close them together