How to create E-R diagram in mysql - mysql

I am using MySQL. There are 28 tables in my database. I've tried to use MySQL Workbench to create E-R diagram. As there are 28 tables, everything is messed up in diagram using MySQL Workbench. Is there any way to create E-R Diagram which shows all relations properly between 28 tables??
Thanks

The only free app I've been able to find that generates decent graphics (not beautiful but quite clear) is SchemaSpy. It's a command line Java program that generates quite comprehensive HTML documentation for any DBMS.

To Create ER Diagram in MySQL follow these steps:
1.First install MySQL Workbench in your computer
Click File->Import->Reverse Engineer MySQL Create Script.
Click Browse and select your SQL create script.
Make Sure "Place Imported Objects on a diagram" is checked.
Click Execute Button.
Click Model->Add Diagram.
Open Catalog Tree and select/drag your tables on your ERR diagram.

ERWin is another good tool. Allowing you to generate erd from sql code and sql code from er diagrams. Its a Drag and Drop utility.

SQL yog is one of the best tool which generate ERD and represents the relationship between different tables.
It is also drag and drop utility and provide complete access to your mysql database.

Open the MySQL Workbench and then go to Database -> Reverse Engineer (in this wizard you have 7 steps to generate the ER Diagram)
1-Connection Options:
For Stored Connection :( Select local instance )
For Password: Click on the Store in Vault.. and then enter your password
Then click on the next.
2-Connect to DBMS:
Click on the next (In this step you do not need to do anything)
3-Select Schemas
Here, select your desire Schema in order to generate an ER Diagram
4-Retrieves Objects
Click on the next (In this step you do not need to do anything)
5-Select Objects
In this step, you can click on the Show Filter to exclude some table if you like
Here, I exclude the emailAddresses table in order not to show that in the ER Diagram
6-Reverses Engineers
Click on the next (In this step you do not need to do anything)
7-Results
Click on the finish to see the Diagram

Related

mySQL - populating the tables in EER diagram and generating .sql file

I'm newer to mySQL and I'm having some difficulty generating a .sql file with insert statements:
I have made an EER diagram, forward engineered this diagram to generate the database, then used the insert statement in the terminal to insert values into my tables.
Now I'm having difficulty bringing this new/updated database back to mySQL workbench and create a .sql file of the whole thing (schema+ what was inserted into the tables).
I had no luck looking here or searching videos on uTube. Any help/links is highly appreciated to show the step by step walk through.
if you have logged into MySQL workbench then tried going to the schema tab (on the left) and hitting the two arrows that make a circle -- that should populate any tables that you've inserted into terminal. if not you can manually add the script file using one of the button on the top left "open a SQL script file". Check out this tutorial for more info.

Adding new table to ER Diagram

I created database and ER Diagram. Then I added new table to exsisting database. Now I would like have this table in my ER Diagram. How can I do it? Have I to create new Diagram? Of course I can use the table tool on the vertical toolbar, but if I have new table I suppose that is better way to get this table in Diagram.
First, always upgrade to the latest MySQL Workbench version (at the time being 6.0.9 with 6.1 around the corner).
I assume you created your EER diagram from the database via reverse engineering. Any time you want to update either the model or the database (schema) run the synchronization in MySQL Workbench. Open a model and go to Database -> Synchronize Model.... This is a two-way tool (model to schema and schema to model), but you can manually define the direction (or to ignore a change). Once you have synchronized your changed schema the new table will appear in the catalog tree where you can drag it to a diagram.
There should be a pane on the left titled Catalog Tree in the tab for your existing EER diagram.
You can drag and drop your new table onto the existing diagram. If the table isn't listed, do a refresh on the dbname in the tree view.

MySQL Workbench Forward Engineer from only the current diagram

I want to create a test database from a huge schema in MySQL, but when I try to do Forward Engineer from a Diagram with about 6 tables, it try to create all the tables, views and routines groups that I have in the schema.
Is there an automatic way to do that instead of selecting one by one the tables I want?
There's no way other than using the filter settings. Add a feature request at http:/bugs.mysql.com for a way to select only the current diagram for sync/forward eng.

Is there a simple way to directly convert Web-based MySQL DB into ER Diagram?

I have a domain, for which I got a website created by someone. They have used MySQL as the DB, but did not do a good job of documenting this and now it is a total mess where I do not know how the DB Tables connect to each other (there are still only 73 tables in 2 DB's).
I have the option of downloading all the table schemas into SQL statements, Excel, etc., but wish to figure out a way to create a ER diagram from the DB Tables on the site itself, so I can replicate it later.
Is there a way to get the ER diagram from the tables on the site itself? If not, which is the best way to convert the SQL Schema into an ER Diagram?
You should look at MySql WOrkBench
I have used Squirrel SQL Client to view the relationships between tables visually. You can select any table and view "tables that depend on that table" or view "all related tables".
Also look at the tutorial here

MySQL Workbench - How to synchronize the EER Diagram

I am creating a visual representation of my existing database with MySQL Workbench and I am able to synchronize the models with the "Database -> Synchronize Model..." menu. However, every time I synchronize (update) my model, I have to recreate the EER Diagram and rearrange all the tables. Is there a way to update or synchronize the EER Diagram as well? Thanks.
Database > Synchronize Model...
Choose Stored Connection
Select the Schemata
Choose which to update: Model or Source (in your case, point arrows to Model)
Are you by any chance using a MySQL DB engine that doesn't support foreign keys (e.g. MyISAM?)? Hence, the relations between the tables is not saved on the MySQL server and get lost during synchronization to the workbench.
But I realize this is only the 'why' of your question. I cannot provide an answer that would preserve your arrangement without using an engine that supports foreign keys, e.g. InnoDB.
I was having a variant of this problem--somehow when I would update the model from the database, one of my tables and its corresponding updatable view wouldn't update.
I believe what was happening is that the model was actually updating, but not the diagram. I didn't really make the distinction at first.
Anyway here's how to get the refresh on the E/R diagram:
Delete the nonupdating object(s) from the diagram. (Just right click and choose "Delete".)
Find the objects in the catalog view in the left sidebar.
Drag them back onto the diagram.
Now they should reflect the model (which should reflect the DB if you followed the accepted answer above.)
When I have more than 3 tables to sync, with changes on relations, I changes arrow direction (model <- source), I check "Skip DB changes and update model only" and Execute...
The "Progress of Model and Database Synchronization" window hang with "Apply changes to Model" highlighted. No processor working, nothing move...
I click the X of the window and redo the process again. Clicking the DB, ignore (all), and selecting less tables to update.
v.5.2.44 ce rev 9933
EDIT: Version 5.2.47 correct this bug !!! YĆ© !