The other day, I was reading a blog by Magnus Hagander about tracking foreign keys throughout a schema in PostgreSQL. I thought it was a good idea, so I decided to look at how you can track foreign key in MySQL.
The way I decided to do it was to start out with a table, then
find all tables referencing the table by a foreign key. From this
basic (and simple as it will be shown) query, it is possible to
create a chain of relations. The key table for the queries is