Exercise - Create table relationships

Completed

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

  1. Sign in to the Power Apps maker portal.

  2. In the left navigation pane, select Tables, select New table, and then select Set advanced properties.

  3. In the Properties table of the New table pane, enter the following values:

    • Display name: Trick

    • Description: Pet Tricks

  4. Select the Primary Column tab and enter the following value:

    • Display name: Trick Name
  5. At the bottom of the pane, select Save.

  6. On the Trick table, select New and select Column.

  7. In the New column pane, enter the following values:

    • Display name: Level

    • Data type: Choice

  8. Create the choice values:

    1. Select New choice to display the New choice pane.

    2. In the Display name field, enter Level.

    3. Under Choices are two entry fields titled Label and Value. Enter Beginner and 1 respectively.

    4. Select New choice under the Beginner entry and make Proficient the new entry for Label and 2 for Value.

    5. Select New choice under the Proficient entry and make Expert the new entry for Label and 3 for Value.

    6. Select Save.

  9. 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

  1. On the Trick table, select New and select Column.

  2. In the New column pane, enter the following values:

    • Display name: Pet

    • Data type: Lookup

    • Related table: Pet

    Screenshot of Pet lookup column.

  3. 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

  1. Select Tables in left-hand navigation of the Power Apps maker portal, and then select the Account table.

  2. On the Schema pane, select Relationships to display the existing relationships on the screen.

    Screenshot of the Schema pane with the relationships button highlighted.

  3. At the top left of the screen, select the New relationship, and then select One-to-many in the dropdown.

  4. In the One-to-many pane on the right, in the Related (Many) list, select Pet.

  5. 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.

    Screenshot of the Account column of the lookup data type automatically added.

For more information, see Create and edit One-to-many or Many-to-one table relationships using Power Apps portal.