| Zoha Zulfiqar
Relationships between entities show how rows can be related to each other in the database. In Microsoft Dataverse, creating relationships is a little different than other platforms. There is no concept of primary key and foreign key, Dataverse makes it simpler for a user to create relationships. It offers the following relationship choices for an entity:
- Many-to-one Relationship
- One-to-many Relationship
- Many-to-many Relationship
Suppose we have an entity called Employee, which is consisted of all the employees of the company, and another entity named Department, which has information about all the departments. Taking that scenario as an example, let’s go through each relationship type one by one.
In this kind of relationship, each row in Employee table can match more than one row in Department table, but each row in Department table can match with only one row in Employee table. For example, an employee belongs to more than one department.
To create a many-to-one relationship, we can either create a lookup column in the Employee table or we can create a relationship from Relationship tab in the table.
To create a lookup column, simply create a new column in the Employee table – assign it Data Type of Lookup – then select the related entity, which in this case is Department.
As the name suggests, it is the opposite of the relationship defined above. Each row in Department table can match with more than one row in Employee table, but each row in Department table can match with only one row in Employee table. As in many employees belong to one department.
After creating a many-to-one relationship from Employee to Department, if you go to Department table, you’ll see an already created relationship of one-to-many from Department to Employee.
This type of relationship is different from the other two types, it can be used when each row in Employee table can match with more than one row in Department table and each row in Department table can match with more than one row in Employee table. For example, many employees can work in many departments.
To create a many-to-many relationship, go to either Employee or Department table – in the Relationships tab – click on Add relationship – then select Many-to-many - after that, you can select the related table. Creating this relationship will not add any lookup column in any of the table but you can see the details in the Relationship tab.
Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.