Generating email / view based on relationship between forms

Generating email / view based on relationship between forms

I have two forms, the first contains customer information (customer ID, name, email, etc) and the second contains store information (store ID, address, email, etc).  Each customer needs to be associated with a particular store. Both forms share the field 'store ID' for this purpose.

I am trying to develop a way for a store owner to receive an email each time that store gets a new customer. So in other words a script should check at a regular interval (say once a day) the relationship between the two forms. If it finds that a new customer is linked to an existing store ID, then it should send that particular store owner an email. It should also be able to update a field to indicate that it has sent the store owner an email, so that it doesn't re-send the same new customer notification to the same store.

I hope that makes sense. How would I achieve this?

Thank you.