Say I have record customers and record transactions. Each transaction has a customer ID field pointing to the customer record.
Obviously if you delete a customer record, you have to delete all the transactions first, to avoid dangling pointers, IDs for which the corresponding record no longer exists. But I inherited this database and I want to make sure that there were no past coding errors leaving inconsistencies in the DB.
If I want to verify that there are no dangling pointers (no customer_id values for which customers.id does not exist), what kind of query would I use?