How to view relationship in mysql workbench

  1. First make sure you have a Database and Tables created on the MySQL server.

How to view relationship in mysql workbench

Example :-

Database - bank.

Tables - account, branch, customer, loan, trandetails.

2. Click on Database -> Reverse Engineer.

How to view relationship in mysql workbench

3. Select your stored connection (for connecting to your MySQL Server in which database is present) from the dropdown. Then click Next.

How to view relationship in mysql workbench

4. After the execution gets completed successfully (connection to DBMS), click Next.

How to view relationship in mysql workbench

5. Select your Database from the MySQL Server for which you want to create the ER Diagram (in our case the database name is “bank”), then click Next.

How to view relationship in mysql workbench

6. After the retrieval gets completed successfully for the selected Database, click Next.

How to view relationship in mysql workbench

7. Select the Tables of the Database which you want to be visible on the ER Diagram (In this case I am importing all the tables of the DB), then click Execute>.

How to view relationship in mysql workbench

8. After the Reverse Engineering Process gets completed successfully, click Next.

How to view relationship in mysql workbench

9. Click Finish.

How to view relationship in mysql workbench

Now you can see the ER Diagram of the Database.

How to view relationship in mysql workbench

How can I see relationships in MySQL?

To see foreign key relationships of a table: SELECT TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA. KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = 'db_name' AND REFERENCED_TABLE_NAME = 'table_name';

How do I find the ER diagram in MySQL Workbench?

4 Answers.
Go to "Database" Menu option..
Select the "Reverse Engineer" option..
A wizard will be open and it will generate the ER Diagram for you..

How do you create a relationship in a workbench?

To create a relationship in MySQL Workbench: Create a database model (either create a new model or reverse engineer an existing database) Viewing the database model, double click on the first table of the relationship. The bottom pane will open with the table details.