title: Find dependencies between tables in sql database
body: <p>I have a Sql database with data. I have been asked to populate a fresh identical database with all the required master data so that the application is able to up and run for a new customer. </p>
  
  <p><code>First approach</code></p>
  
  <p>Delete all the data from database, run the application, sure i won't be even able to login. Observe errors, identify tables which need master data(sure <code>User</code> table at least), insert data. Then assume i am going to access a module. But without some master data it'll give me errors. Observe errors, identify tables which need master data, insert data.
  But this seems not practical.</p>
  
  <p><code>Second approach</code></p>
  
  <p>While keeping the data in database, take one table at a time, using queries or sql server management studio tools, find all dependent tables. Keep the parent table data and delete child table data. Do this for all tables. In second round consider the remaining parent tables. Some table's data are inserted from application. Identify those and delete them. This way i can have relevant master data at the end. But i don't know how to approach this.</p>
  
  <p>All these are my thoughts. Sure there might be many more approaches which are more precise and easier than these.I am confused with what to do. Please guide me. Thanks! </p>