Learn how to use four simple steps and a data modeling tool to create a database diagram online.
Creating database diagrams (aka data modeling) is an essential part of modern database development projects. A good data model is to a database what a strong foundation is to a skyscraper. Due to the availability of modern data modeling tools, this has become a straightforward process.
What Is Data Modeling?
Data modeling is the process of identifying and graphically representing the data elements and entities along with their attributes, relationships, operations, etc. This is the first step to developing large database systems.
Data modeling starts with the conceptual level, where a high-level database diagram represents the basic entities and their relationships. This model is used in system analysis and in the database planning stage to communicate with the business team. It makes collecting and finalizing the business requirements for the proposed database system much simpler.
When the conceptual model is finalized, we can move forward with the logical data model, which incorporates more details like data types. This leads to the physical data model, which adds database-specific information to the logical model and prepares the implementation of the actual database. Modern data modeling tools have automated features that simplify the process of moving from the logical to the physical data model and implementing the physical model.
Let's walk through the steps of database design using Vertabelo, a modern online database diagram tool. These tips for better database design may also be helpful when you are designing your own data model.
What Are the Steps in Database Design?
Step 0: Planning
Database architects use this phase to gather the requirements for the database – well before they start any kind of design work. There are many ways to gather business requirements, including observing the current system, interviewing users and stakeholders, and brainstorming sessions with your team. During this phase, you can plan the rest of the process and allocate tasks among team members.
After a proper planning process, you can start the basic database design. Let's use Vertabelo to create an example data model for an online shopping app. The document we create is called an entity-relationship diagram, also known as an ER diagram or ERD.
Step 1: Identifying Entities
In the first stage, we will identify the real-world entities that should be considered in our database system. An entity can be a person or a thing that comes under the scope of the proposed system. We will keep data about these entities in the database; each entity will have a separate table. For our online shopping app, we can identify the following entities:
- Online Customer
- Shopping Cart
- Shopping Cart Item
- Product
Once you’ve identified your entities, you are ready to start drawing your conceptual ER diagram. In Vertabelo, you can choose your preferred ERD notation under Model Properties:
Then you can use these notations to draw your conceptual model:
Your conceptual data model will look something like this:
Step 2: Adding Attributes to Entities
Now it's time to add more details to your data model. In this step, you’ll identify and add attributes to each entity. Attributes are the properties of an entity; you can learn more about the differences between entities and attributes here. For instance, the attributes of the Online Customer entity would be the person's name, phone number, address, date of birth, account number, etc. Each attribute has a data type that defines what kind of data we will assign for each attribute. For example, we save a person's name in text characters and their date of birth in a date format.
To add attributes to your entities in the Vertabelo data modeler, click on the entity and use the Entity Properties panel on the right. Here you can add attributes with their data types, make them mandatory or nullable, and set one or more as the primary key.
We’ve added attributes with their data types into our logical data model:
Step 3: Adding Relationships Between Entities
Next, we need to identify and add relationships between these entities. Relationships show how the entities of your system are connected with each other. These relationships help us to connect database tables through foreign keys. For instance, these are the relationships between the entities in our online shopping app.
- An online customer can have many shopping carts. On the other hand, one shopping cart belongs to only one online customer. According to this description, we have a one-to-many relationship between the online customer and the shopping cart.
- A shopping cart may have many shopping cart items; however, one shopping cart item belongs to only one shopping cart. Again, we have a one-to-many relationship between the shopping cart and the shopping cart item.
- A shopping cart item contains only one product. But one product can exist as many shopping cart items. Based on that, we have a one-to-many relationship between the product and the shopping cart item.
We’ll reflect these relationships in our logical diagram. To create a relationship between two entities in Vertabelo, click on the appropriate relationship in the toolbox at the top, click on the first entity, and drag and release on the second entity.
You can change the properties of a relationship by clicking on it and changing its properties in the Relationship Properties panel on the right:
Vertabelo validates your model by highlighting entities with default names, missing attributes, entities without a primary identifier, etc.
Step 4: Preparing the Physical ER Diagram
Now we can create our physical ER diagram. Conveniently, Vertabelo has an automated feature that converts your logical data model to a physical data model. Now we can create the physical ER diagram in a few steps.
Click on the model name, which opens the main menu. Then click Generate physical model.
You can change the suggested name for your physical model and select the target database engine from the dropdown list. Click Generate Physical Model to create the physical data model from your logical model.
Below is the physical data model (for the MySQL database engine) for our online shopping app. You can learn more about creating a physical diagram from a logical diagram here.
Vertabelo validates your physical model against the selected database management system’s constraints and shows you errors or warnings. You can see some highlighted in the above image; we need to correct them.
When you select an entity in Vertabelo, you can see the table properties on the right. You can change and correct your table properties there.
The corrected model looks like this:
The Vertabelo online SQL data modeler offers many other features that make team data modeling collaborations easy. For example, you can use text notes to make complicated database models more understandable. To create a new text note, click Add note in Model structure or click the Add new note icon in your toolbox. Then click wherever you want to create a note. You can also just press 6 on your keyboard.
You can also add color to your diagrams. Select the table and go to the Format section (under Additional Properties) in the Table Properties panel on the right.
We’ve done it! We’ve completed our physical data model:
Ready to Create Your Database Diagram Online?
Creating a database diagram is the most crucial part of the database development process. In this article, we’ve gone through the steps to create a database diagram from scratch. Try it yourself with Vertabelo!