Finding Foreign Key Chains

Suppose that you want to find all of the tables in a database which are related via foreign key constraint.  Here's an easy example: suppose T3 has a foreign key (T2ID) to T2, and T2 has a foreign key (T1ID) to T1. Given a table name (T2, say), we want to return T2, as well as…

Advertisement