With MySQL Workbench it is possible to create a graphical ER diagram; however, this can become very messy when there are many tables and relations, so it might be good to have something like one or more text trees, like this, where TABLE1 has a foreign key to TABLE2A, TABLE2B and TABLE2C, and TABLE2B has a foreign key to TABLE3A and TABLE3B:
TABLE1 -+- TABLE2A +- TABLE2B -+- TABLE3A | +- TABLE3B +- TABLE2C
and so on. Is there a tool that can produce that?
Having thought a bit, I realise that I can create a list like this:
mysql> select distinct table_name,referenced_table_name -> from key_column_usage -> where table_schema='demoplay' -> and referenced_table_name is not null -> order by table_name;
I can probably create a
greater_than function based on this in python and then sort things, and perhaps from there print it out nicely.