Adding references to your data model is essential to maintaining clarity.
A Quick and Easy Introduction to Entity Relationships
In data modeling, defining relationships between tables/entities entails using a certain notation to indicate the cardinality between them. This applies to both logical and physical data models.
Cardinality refers to how many instances of one entity are related to the other entity. For example, a database that keeps track of orders on an e-commerce website likely has
Think about your own experiences with ordering items on an e-commerce website such as Amazon, eBay, or Newegg. You placed an order for some items a few weeks ago, and now you place another order with the same e-commerce site again, be it for the same or different items. You may have various orders over time with the same e-commerce site.
Hence, it is logical to say one
customer entity can be associated with 0 or more orders. We have already identified the cardinality between the two tables. All that is left is to articulate it in the data model itself by choosing among the following notations: Crow’s Foot, IDEF1X, UML, and Barker’s.
In data modeling, it is particularly important to indicate the type of cardinality between two entities. In the next section, we review the most common types of cardinalities: one-to-one, one-to-many, and many-to-many.
For more information, take a look at this useful blog on how to use an ER diagram.
Types of Cardinality
- One-to-one. Only one instance of Entity A can be linked to only one instance of Entity B. For example, in a school database system, a
classis usually held in only one
classroomat any given time and vice versa.
- One-to-many. One instance of Entity A can be linked to many instances of Entity B. However, the reverse is not true. That is, one instance of Entity B cannot be linked to many instances of Entity A. For example, in a database for an e-commerce website, a single customer can have many orders. Hence, an instance of the
customerentity can be associated with several instances of the
orderentity, but the reverse is not true.
- Many-to-many. Several instances of Entity A can be associated with several instances of Entity B and the reverse is true. For example, in a library records system, an instance of the
bookentity can have several associations with the
authorentity and the same is true in reverse.
Types of Notation
Cardinalities between entities can be expressed in different notations, the most common of which is the Crow’s Foot notation. However, there are other common notations such as IDEF1X, UML, and Barker’s.
Adding References in Vertabelo
Here is a detailed step-by-step guide on how to add and configure references between entities/tables. We explain important configuration steps such as how to define cardinalities and how to change notation types.
Adding a Reference
Click on the Reference button in the toolbar.
Click and hold on to the first of the two entities you want to connect. Do not release the left mouse button, as you need to drag your cursor to the second entity later.
Drag your cursor onto the second entity. You should see a dotted line forming as you do this.
Release the left mouse button. When you do this, a reference is added.
Assigning Primary and Foreign Keys
If you have already set your primary keys in your tables before adding a reference, the corresponding foreign keys are created automatically. To make more changes, simply choose which column corresponds to which in the dropdown menus below.
You can specify whether the relationship is optional or mandatory using the checkbox right below the primary and foreign key dropdowns.
Configuring the Cardinality
To configure the cardinality, direct your attention to the right toolbar. There is a dropdown called “Cardinality”. “0..*” refers to one-to-many with a 0 modality, “0..1” refers to one-to-one with a 0 modality, “1..*” refers to one-to-many with a 1 modality, and “1..1” refers to one-to-one with a 1 modality.
Next, direct your attention to the “Diagram elements” section. A dropdown named “Reference notation” is available. Once you click that dropdown, you can switch freely between different kinds of notations.
Adding References Is Easy in Vertabelo
Vertabelo enables users to add references to their data models quickly and easily. It supports the four most common notations: Crow’s Foot, UML, Barker’s, and IDEF1X, with enough flexibility to allow the configuration of elements such as cardinality and modality.