Cascade relations

  • I have a database with 100+ tabes. I am tasked to find out the cascade relations amongst the tables, so that we could delete the records of the database easily using cascade delete. My question is : Is there any script that gives the relations of the tables in a readable format. I see one way is to create the DB diagram and study for each relation. However I am looking for something that generates the report like format so that it can be compared to the same DB in another environment.

    Please let me know

  • The only thing I ever saw was a "best guess" script. It was matching the tables by finding columns with the same name and IIRC data types.

    Now that will only work if the schema is perfectly named based on a business rule. However since the FKs are not created then you'll most likely find that you are out of luck in the department.

    What I'd do is start a trace and read the object definitions of all the views / table functions and sps, etc.

    Pick out the joins one at a time and start scripting the fks in a test db.

    Any way you approach this, this is a monumental task for a system with 100 tables. Better set aside a few weeks to do this (I've never done that without having to clean the data, ddl design and code, hence MONUMENTAL task).

  • Thanks.

    Any one has a script. Thinking of something that will read the object definitions and map the relations. Please let me know.

  • That was doing a good job in 2003. I have not tried it since so maybe it can help you out.

    There's a free trial so you should have enough time to check it out before having to buy :

    http://www.red-gate.com/products/sql-development/sql-dependency-tracker/

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply