db: initial referential integrity checking