Database consistency check