Exercise - Create table relationships
In this unit, you create a table and then add relationships between tables. You learn how to:
- Create a relationship by using a lookup column.
- Add a One-to-Many table relationship.
The simplest way to add a table relationship is to create a lookup column to another table. This automatically creates a parent-child relationship between tables.
Note
The Dataverse Pet table referred to in this unit was created in the previous exercise. You need to create other tables to add relationships to.
Create a custom table and add a column
Sign in to the Power Apps maker portal.
In the left navigation pane, select Tables, select New table, and then select Set advanced properties.
In the Properties table of the New table pane, enter the following values:
Display name: Trick
Description: Pet Tricks
Select the Primary Column tab and enter the following value:
- Display name: Trick Name
At the bottom of the pane, select Save.
On the Trick table, select New and select Column.
In the New column pane, enter the following values:
Display name: Level
Data type: Choice
Create the choice values:
Select New choice to display the New choice pane.
In the Display name field, enter Level.
Under Choices are two entry fields titled Label and Value. Enter Beginner and 1 respectively.
Select New choice under the Beginner entry and make Proficient the new entry for Label and 2 for Value.
Select New choice under the Proficient entry and make Expert the new entry for Label and 3 for Value.
Select Save.
Select the drop-down list under Sync this choice with, find/select Level, and then select Save.
Create a relationship by using a lookup column
On the Trick table, select New and select Column.
In the New column pane, enter the following values:
Display name: Pet
Data type: Lookup
Related table: Pet
Select Save.
Now that we've done this, if you look at the table relationships, you'll see that the new Pet column now has a Many-to-one relationship with your Pet table. Conversely, your Pet table now has a One-to-many relationship with the Trick table, even though we haven't created a Trick column in the Pet table, yet.
Add a one-to-many relationship
Select Tables in left-hand navigation of the Power Apps maker portal, and then select the Account table.
On the Schema pane, select Relationships to display the existing relationships on the screen.
At the top left of the screen, select the New relationship, and then select One-to-many in the dropdown.
In the One-to-many pane on the right, in the Related (Many) list, select Pet.
Select Done.
Notice that when you add a many-to-one relationship, an Account column of the Lookup data type is automatically added to the list of columns on the Pet table.
For more information, see Create and edit One-to-many or Many-to-one table relationships using Power Apps portal.