62

For CakePHP application, I created MySQL database.

Which tool to be used to create ER Diagram of database? Fields and relations between tables are created in a way cakePHP likes.

thank you in advance!

Tiny
  • 27,221
  • 105
  • 339
  • 599
user198003
  • 11,029
  • 28
  • 94
  • 152
  • The question does not seem Cake PHP specific and has been answered here before: https://stackoverflow.com/questions/2488/auto-generate-database-diagram-mysql – s.Daniel Nov 30 '12 at 08:34

4 Answers4

115

Use MySQL Workbench. create SQL dump file of your database

Follow below steps:

  1. Click File->Import->Reverse Engineer MySQL Create Script
  2. Click Browse and select your SQL create script.
  3. Make Sure "Place Imported Objects on a diagram" is checked.
  4. Click Execute Button.
  5. You are done.
CJ Ramki
  • 2,620
  • 3
  • 25
  • 47
varun249
  • 1,436
  • 2
  • 11
  • 9
  • 4
    This worked for me, but I cannot see the relation between table? any idea? suggestion? – Paulo Almeida Oct 22 '14 at 10:43
  • Worked fantastic for me as well. But same problem. Can't get the relations between the table. – danialzahid94 Sep 05 '15 at 02:59
  • 26
    In a recent version of MySQL Workbench (6.2, Windows) the option is in Database > Reverse Engineer. When importing a MySQL 5.6 database it included foreign keys for me. – AronVanAmmers Sep 23 '15 at 14:53
  • 1
    As of 6.3 for OS X, Database > Reverse Engineer works great. No issues with table relations, they're included. – Lane Rettig Jan 26 '16 at 20:09
  • tried with apache derby sql. worked as a charm. thanks. – Tanatos Daniel Sep 03 '16 at 20:33
  • This worked perfectly for me. Thanks! – Amol Jadhav Apr 20 '18 at 05:16
  • Have a 50 table db with properly defined foreign keys in all tables. It does not find all the relationships. I say only finds about half of them. Also when trying to manualy make the relationships it creates new table fields that are not there. Also seem not to be able to edit the imaginary fields it creates. – Andy N May 31 '23 at 14:54
41

Try MySQL Workbench. It packs in very nice data modeling tools. Check out their screenshots for EER diagrams (Enhanced Entity Relationships, which are a notch up ER diagrams).

This isn't CakePHP specific, but you can modify the options so that the foreign keys and join tables follow the conventions that CakePHP uses. This would simplify your data modeling process once you've put the rules in place.

RabidFire
  • 6,280
  • 1
  • 28
  • 24
  • I was under the impression that EER Diagram was "Entity-Entity Relationship Diagram" ... and I do recommend MySQL Workbench as well. – serialk Dec 02 '10 at 05:37
  • Check out: http://en.wikipedia.org/wiki/Enhanced_Entity-Relationship_Model – RabidFire Dec 02 '10 at 06:32
  • If you have a M:N relation without a pivot table, there seems to be no way to in MySQL Workbench to draw such a relation without introducing a pivot table. It also creates columns when placing relations when the existing columns do not follow its own convention for naming. So to me MySQL Workbench does not look all that productive for reverse engineering an existing schema. It seems more intended to design a new schema using opinionated (though probably good) practices. – jerseyboy Feb 21 '14 at 19:08
  • but how to make this happen in workbench in Ubuntu its quit different – numerah Jun 30 '14 at 05:49
  • 4
    The screenshot looks great, but you never actually tell us how to get there. This should not be the accepted answer. – Ozymandias Aug 12 '17 at 23:56
12

If you don't want to install MySQL workbench, and are looking for an online tool, this might help: http://ondras.zarovi.cz/sql/demo/

I use it quite often to create simple DB schemas for various apps I build.

Suman
  • 9,221
  • 5
  • 49
  • 62
4

CakePHP was intended to be used as Ruby on Rails framework clone, done in PHP, so any reverse-engineering of underlying database is pointless. EER diagrams should be reverse-engineered from Model layer.

Such tools do exist for Ruby Here you can see Redmine database EER diagrams reverse-engineered from Models. Not from database. http://redminecookbook.com/Redmine-erd-diagrams.html

With following tools: http://rails-erd.rubyforge.org/ http://railroady.prestonlee.com/

Aleksandar Pavić
  • 3,143
  • 1
  • 34
  • 36