Mysql workbench not showing realtions after reverse engineering database - mysql

I'm using MySQL workbench 5.2.35 CE to reverse a Mysql Database and show the diagram of tables with their relationships.
I am able to get every table and its fields but the relations between them is not shown. Why is that? Is there any way it can be fixed?

Most often, the relations between tables are not stored in the DB. How to combine two tables is entirely up to the SQL query and because there are near endless possibilities to name your columns this is not easy to guess. Try to find some SELECT statements or use brute force to find out wich columns match.

If you are using MyISAM as the database engine, your database is not fully relational. Make your database fully relational by using InnoDB engine. Then you will be able to see the relations when you do reverse engineering. But please note that each has pros and cons of its own. Google MyISAM vs InnoDB to find out more about the differences.

I have tested mysql-workbench for both 5.2 and 6.0 latest version. My database got foreign key constraints defined clearly. My database is using mysql-native SQL. But the relationships are shown as line between tables. I have created another test database with only two tables. In this case the InoDb was used as engine. The foreign key constrain clearly defined. Still it only generate two lonely table object in the ER diagram after going through the "reverse engineering" module.
While using another commercial software, I was able to generate the 'lines' between the Entities.
My question is, is this a problem of workbench itself, or some error on my part. My database server is the latest stable version 5.6.12. If I can get an answer, this will be good for everyone. You don't have to waste time trying to get an ER-diagram with this piece of software.

Related

'Magic' ERD generator MySQL, MS SQL

I haven't managed to find a specific answer to this question which works for me, but maybe i'm misunderstanding one or two key points.
I am trying to create a data migration policy for a project where 3 systems (2 X MySQL, 1 X MS SQL) are being consolidated into 1 new system (MS SQL).
To help visualize this problem i want to create Entity Relationship Diagrams for each database. I know how to reverse engineer each database to a sql script, and i know that programs like MySQL Workbench and SQL server management studio have tools which allow you to create diagrams.
My question is: Is there any way to create the diagrams automatically? I.e. somehow analyse foreign keys and detect which field(s) in table A link to table B and insert links in the diagram between the correct fields?
SQL Server Management Studio comes with a diagramming tool. In the Object Explorer, expand your database, then right click on Database Diagrams. You can view and create new FK relationships in there.
I have just realised that the databases i am testing with do not have foreign key constraints set up properly. So i guess the answer is yes, there are ways you can create these diagrams automatically but the foreign keys must be configured.

MySQL Workbench - Fix Index Names Warning

I have a new client that is running a Symfony application with 170 or so MySQL tables. He recently updated his MySQL Workbench to the latest revision and is now getting a warning pop-up when he launched the application
FIX INDEX NAMES
Index names identical to FK names were found in the model, which is not allowed for MySQL5.5 and later. Would you like to rename the indexes?
I am not a DBA but I understand that the index and primary key names are clashing. What are the implications of renaming these indexes vs. just ignoring?
The Symfony app he is running uses the Doctrine ORM, would any queries or the model need to be updated should the indexes be renamed?
Using the InnoDB engine
Thanks
MySQL Workbench checks at opening a model if there are any duplicate index names and offers to rename them to be unique. Letting it doing this has not bad side effect. In fact it is even necessary to be able to apply the model to a server. Otherwise the server will refuse to create tables that contain an index with a name that was already taken.
So in short: it's a good idea to let Workbench fix this bug (since duplicate key names are nothing but a bug).

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

Combine several mssql database to one mysql with php

We are handling a data aggregation project by having several microsoft sql server databases combining to one mysql database. all mssql database have the same schema.
The requirements are :
each mssql database can be imported to mysql independently
before being able to import each record to mysql we need to validates each records with a specific createrias via php.
each imported mssql database can be rollbacked. It means even it already imported to mysql, all the mssql database can be removed from the mysql.
we would still like to know where does each record imported to the mysql come from what mssql database.
All import process will be done with PHP .
we have difficulty in many aspects. we don't know what is the best approach to solve our problem.
your help will be highly appreciated.
ps: each mssql database has around 60 tables and each table can have a few hundred thousands .
Don't use PHP as a database administration utility. Any time you build a quick PHP script to transfer records directly from one database to another, you're going to cause yourself a world of hurt when that script becomes required for production operation.
You have a number of problems that you need solved:
You have multiple MSSQL databases with similar if not identical tables.
You have a single MySQL database that you want to merge the data into.
The imported data must be altered in a specific way before being merged.
You want to prevent all duplicate records in your import.
You want to know what database each record originally came from.
The solution?
Analyze the source MSSQL databases and create a merge strategy for them.
Create a database structure on the MySQL database that fits the merge strategy in #1, including all the new key constraints (like unique and foreign keys) required for the consolidation.
At this point you have two options left:
Dump the data from each of the source databases into raw data using your RDBMS administration utility of choice. Alter that data to fit your merge strategy and constraints. Document this, and then merge all of the data into your new database structure.
Use a tool like opendbcopy to map columns from one database to another and run a mass import.
Hope this helps.

Determining dependent tables in MySQL?

In MySQL, I need to know which tables depend on other tables. Is it possible to get the relations?
In SQL Server it's possible to see dependent tables. I hope MySQL can do this too.
If it's in pictorical form then that's even better.
Perhaps you want the SHOW CREATE TABLE command?
If there are foreign keys defined, the above command will show you what they are.
Take a look at the information_schema, especially to key_column_usage table.
http://dev.mysql.com/doc/refman/5.0/en/key-column-usage-table.html
Have a look at Database Explorer (object dependency tree) - a unique feature in dbForge Studio for MySQL.
Easily explore object's references and dependants in Database Explorer. Compilation of dependants for debugging is now also available through the object's context menu.
Also, Database Designer can show foreign key relations between tables.
maybe you'd want a graphical front-end to mysql since you're so used to SQL Server. if the foreign keys are defined, it will show up as a link between entities when you reverse engineer the database.