I have a MySql DB structure with foreign keys, how can I generate a diagram for it with table connections for foreign keys.
I need to clear the DB so have to find the table dependencies thats why I want to generate tables with connections.
There are keys in tables such as KEYFK228141202DDB7295
What is the tool for this?
Tools I know include MySQL Workbench and SchemaSpy. SchemaSpy is not MySQL specific and may be harder to set-up but it generates better graphs IMHO.
Related
Is there any option in MySQL forward engineering which can generate FOREIGN KEYS as ALTER TABLE STATEMENT?
Forward engineering in MySQL Workbench is the process of applying a modell as a whole on the target server. Existing objects are "overwritten".
In your case use the synchronization feature (a 2-way merge) that allows to apply individual changes via ALTER TABLE etc. on the target db. At the same time changes in the target schema that are not yet in the model are taken over, so both model and server are in sync after that.
I have got a database in MS Access format and I want to export it to MySQL. I used this tool to import the database to MySQL successfully. However when I try to do "Reverse Engineer" in MySQL Workbench to draw its schema, all I get is tables without relationhip links. Is there something I am missing?
Relationships can only be drawn for foreign keys. If you don't have foreign keys (e.g. only MYISAM tables) then you won't get any relationship. Try the migration module from MySQL Workbench to see if that gives you more in your target schema (tho no promises). If all fails you have to manually add foreignkeys and thereby getting relationships.
Our MySQL database application crashed. We had a backup and restored it about a week after the system crashed. Meanwhile we used a backup database application. How can I add the data from this week's gap to the database.
What would be the best way to do this?
EDIT.
The table structure is the same. There are a number of tables with foreign keys.
Essentially my question boils down to this:
Primary keys on the two servers look like this:
serv1: 123456---
serv2: 123---456
All these are foreign keys in the secondary table
I would like to merge the two, but have all the primary keys in the second table to be reflected in the foreign key relationship when I move the corresponding data from the other tables.
If you have few versions of the database which i guess you do now, the best way is to synchronize the data between the online database and the missing data.
You can try with: http://www.red-gate.com/products/mysql/mysql-data-compare/
Or: http://www.devart.com/dbforge/sql/datacompare/
With workbench you can compare the schemas:
http://dev.mysql.com/doc/workbench/en/wb-database-diff-report.html
But the best first make an backup on test environment then try the compares, it could be that the same ID exists on two locations and you would need to find the best solution for your database.
So put both databases (the live one and the latest database you have on two test environments)
Synchronize them and check the differences
Run the fix on test if everything goes fine then do that on production.
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.
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.