Account deletion

This branch implements SQL functions for cascaded entity deletion. This is used by the account-deletion branches in the other repos.