So the question gets divided into 2 parts
- Identify the relationship hierarchy
- Start deleting the data from the bottom i.e from child tables to the parent tables
Now the real question, is it really necessary to identify the hierarchy between tables ? Isn't there any other way to perform this ?