How to Generate your schema data tables ?

  • Find your database and export as SQL dump. Structure only.
  • Trim the SQL to only show tables you are interested in.
  • Paste this SQL into the box
  • Click "Generate"


Tests

How it works:

Why:

Jumbling all 3 steps into one would be slightly more efficient for the PC. Who cares about the PC? lolz

The 3 steps are 3 processes, it would be simple to remove the last process and drop it into a mindmap application, or a flowchart app.

How does it find a foreign key?

MySQL: InnoDB

Reads the CONSTRAINT <name> FOREIGN KEY (<column name>) REFERENCES <table> (<column name>) and figures it out.

MySQL: MyISAM

DB syntax naming

MyISAM does not support foreign keys (foreign key constraints are enforced through code) but we can figure out the FKs through naming conventions.

I name my foreign keys fk_table_name this links to a table whose primary key I always call id. Any column names that start or end it assumes are foreign keys:

Example: A table called blog_posts with columns id, fk_author, post. In the diagram fk_author will join to the authors table.

I name a table of clients 'clients', but a table that has a foreign key to the clients table is fk_client (we are linking to a single client), note the missing s. There is a little hack in the code to take this pluralization into account.

Another problem that I have in my tables it that I have a foreign key with a name that has no relation to the table name. For example I have a projects table that has a manager (fk_manager), a sales manager (fk_sales_manager) and a project owner (fk_staff). These are all members of staff, so they all link to the staff table. You can mark these columns to link to the staff table by adding this text to the columns COMMENT attribute:

This is easy to do: