check database for duplicate keys