ERD (Draft)
Overview
On this lesson, we are going to review one of the features related to database that visualize two important topics: major entities within the system and the relationship among these entities. Entity Relationship Diagram (ERD) is a type of structural diagram that we can use in database design.
There are some situations where these diagrams are useful:
Database design: Depending on the scale of change, it can be risky to alter a database structure directly. It is important to plan out the changes carefully.
Database debugging: To debug database issues can be challenging, especially when the database contains many tables, which require writing complex SQL in getting the information needed. By visualizing a database schema with an ERD, you have a full picture of the entire database schema.
Gathering requirements: Determine the requirements of an information system by drawing a conceptual ERD that depicts the high-level business objects of the system.
Let’s check how we can use the ERD in Wayfast!
How to create Entity Relationship Diagrams?
First we need to navigate through the “Database” tab at the top header. Then click on “ERD” section
This section will display all the diagrams associated to the project. Let’s click on “New ERD” button to create a new diagram.
NOTE: Keep in mind that we need to establish an active requirement on the project to create a new diagram. Otherwise, we can only view the existing ERDs in read only mode.
A new tab is opened on the browser, we need to initially input the name of the new diagram and click on “Ok” button.
Automatically the name will be displayed at the header. At this point, we are able to start creating the entities that will represent our tables in database. Let’s right click in any place on the ERD area.
A menu is displayed on screen with different options. Let’s click on “New Table” button
A popup is displayed to enter the name of the table. Once we click on “Ok” button, the new table will be available in the diagram.
On each table created, we can provide all the necessary attributes that are important in our model. If we right-click on the table area, we can create new column properties or delete the ones available. Also we can associate primary and foreign keys.
Another possibility to include new table on our model is using the “Add Existing Table” button. This option will populate all our tables in database.
In our example, we have “HWD_Roles” available from the “Dataset” lesson in the project.
NOTE: We need to synchronize the model object from database in Wayfast to view all the updated existing tables. Otherwise, those recently created tables won’t be available to make the diagram.
All the attributes from the table allocated in the database are populated in the example without creating the new columns. If we create a new column using an existing name, the application won’t be able to save the attribute.
Click on “Save” button before continue working on the diagram.
Back in the “ERD” dashboard, we can observe the new diagram created and the number of tables matches with the ones created in our example. Click on “3” link
Application displays the information for each table with the instance and database connection. We can remove the table if we click on “Delete” icon without opening again the diagram.
Also we can remove the entire diagram or view it again to modify any relationship in the model.
Recap
In the first part, we learnt more about the entity relationship diagrams (ERD) and how they are helpful to build our database model. Then we review the ERD tool available in Wayfast to create the entities in the diagram and make the inter-relationships between all of them.