#MyFirstTechSeries: My First Tech Series is a series of technical topics. It includes step by step instructions along with screenshots. All the steps beginning with software installation is mentioned in the articles. My vision is to help developers to easily follow the steps and get the tech topic working in his/her system. This working demo will save them a lot of time spent collating information from different tutorial sites and YouTube videos.
When I tried to create an Entity Relationship Diagram, I was overwhelmed by the number of ER diagram tools available in the market. The good news is, there are so many tools which help us create the ERD easily. The bad news is, most of the tools are either paid and/or do not allow for collaboration. And then I stumbled upon this eclipse plugin to create an ERD. In this article, I am going to guide you with step by step instructions to create your first ERD using eclipse.
Step 1: Install the eclipse plugin (DBeaver Community Edition).
Step 2: Create a project for the ERD in eclipse.
Step 3: Open the DBeaver Perspective and set up the DB connection.
Step 4: Create the ER diagram.
Step 1: Install the eclipse plugin (DBeaver Community Edition)
More information about DBeaver can be found here: https://marketplace.eclipse.org/content/dbeaver
Navigate to Help -> Eclipse Marketplace. Search for ERD
Choose and install DBeaver Community edition. The version at the time of installing is DBeaver 21.2.0. Hit Confirm with the default selection.
Hit finish after selecting Agree to the terms and conditions.
Software will start to install.
Midway during installation, you will get an exception alert. Hit Install anyway.
Eclipse will ask if you trust the certificates. Hit "Accept Selected".
After installation, eclipse will ask for restart. Hit "Restart Now".
Step 2: Create a project for the ERD in eclipse
Click File -> New -> Project -> DBeaver -> Project. Hit Next.
Give Project name as DemoERDiagram. Hit Finish.
Step 3: Open the DBeaver Perspective and create DB connection.
Goto Window -> Open Perspective -> Other
Choose DBeaver and click OK.
An eclipse perspective as shown will be opened.
Step 4: Open DB Connection
Goto Database -> New Database Connection
Search, find and choose the DB that you want. In our case, we are going to use PostgreSQL. Make sure your project "DemoERDiagram" is selected in the Project Dropdown. Hit Next.
A window pops up. Click "Download" button. This should happen only during the first time.
Give your Postgres credentials and Hit finish. In our case, we just had to specify the password as "admin" and didn't have to change any of the auto-populated values.
After the DB connection is created successfully, the Database navigator looks like below.
Step 5: Create the ER diagram
Goto File -> New -> Other -> DBeaver -> ER Diagram
Give a name for your ER diagram. I have given it as "DemoDiagram"
An .erd file will be created as shown:
*** MAKE SURE YOU HIT SAVE FREQUENTLY WHEN YOU PERFORM THE FOLLOWING STEPS ***
Now Right Click on Tables under Public in the Database Navigator. And select "Create New Table"
A view opens to configure your new table. Make all the relevant changes. I am creating a "Customer" Table and "Customer_Order" Table.
Right click on the table -> Create New Columns and keep adding columns and the datatypes. I have added customerid, customername, customeremail. customerphone as columns.
Under Constraints, Right click -> Add New Constraint. Use this to create a Primary Key constraint for the customer id. Any other relevant constraints (for example: Email unique) can be added here.
Next, I created the customer_order table and added the fields. Again, add the primary key constraint for customerid in this table too,
Create a foreign key constraint too. Just goto Foreign Keys, Right Click -> Create New Foreign Key.
Once you click ok, the foreign key constraint will be created as follows:
We just have one step left. Go back to the DemoDiagram.erd and drag and drop the two tables we just created. And voila, an ERD is created with all the dependencies :)
That's it. We have successfully created the ER diagram. :) Its super simple, connected and very easy (Thanks to the drivers :) )
The following is additional information:
If you check the PGAdmin, you can see that the tables are created there too.
To share the ER diagram (Editable) : You can export the project "DemoERDiagram". Your teammates can import it easily and also work on their system.
To share the ER diagram (Non Editable): You can also export the diagram as a png file. This diagram can be used in your project documents.