Create a relationship between tables

Data in one table often relates to data in another table. For example, you might have a Teachers table and a Class table, and the Class table might have a lookup relation to the Teachers table to show which teacher instructs the class. You can use a lookup column to show data from the Teachers table. This is commonly referred to as a lookup column.

Define a relationship

You can create several types of relationships from one table to another (or between a table and itself). Each table can have a relationship with more than one table, and each table can have more than one relationship to another table. Some common relationship types are:

  • Many-to-one - In this type of relationship, each row in table A can match more than one row in table B, but each row in table B can match only one row in table A. For example, a class has a single classroom. This is the most common type of relationship and is shown in the column list as a Lookup column
  • One-to-many - In this type of relationship, each row in table B can match more than one row in table A, but each row in table A can match only one row in table B. For example, a single teacher, teaches many classes.
  • Many-to-many - In this type of relationship, each row in table A can match more than one row in table B, and vice versa. For example, students attend many classes, and each class can have multiple students.

Additionally, you can set advanced cascading behaviors on many-to-one and one-to-many relationships whenever an action is taken on the parent table.

Add a lookup column (Many-to-one relationship)

To add a lookup relation to a table, create a relation under the Relationships area and specify the table with which you want to create a relationship.

  1. On powerapps.com, on the left navigation pane select Tables. If the item isn’t in the side panel pane, select …More and then select the item you want.

  2. Select an existing table, or Create a new table

  3. Select the Relationships area.

  4. Select Add relationship, and then select a relationship type, such as Many-to-one.

  5. On the right pane, select a Related table for the Current table, and then select Done.

    Many to one relationship example.

  6. Select Save table.

    Many to One Relationship.

Add a One-to-many relationship

To add a One-to-many relationship, create a relation under the Relationships area and specify the table with which you want to create a relationship.

  1. On powerapps.com, select Tables in the left navigation pane. If the item isn’t in the side panel pane, select …More and then select the item you want.

  2. Select an existing table, or Create a new table

  3. Select the Relationships area.

  4. Select the down arrow to the right of Add relationship, and then select One-to-many.

    One to Many Relationship.

  5. Select a table. Notice the Look up columns will be shown on the Current table, they'll default with the tables name (in this example Teacher) but you can change them if needed. Select Done to add the relationship to your table.

    Note

    In the case of a One-to-many relationships, the Look up column will be created on the related table, not the table you currently have selected. If you need the lookup on the current table, create a Many-to-one relationship.

    One to many example.

  6. Select Save table.

Add a Many-to-many relationship

To add a Many-to-many relationship, create a relation under the Relationships area and specify the table with which you want to create a relationship.

  1. On powerapps.com, select Tables in the left navigation pane. If the item isn’t in the side panel pane, select …More and then select the item you want.

  2. Select an existing table, or Create a new table

  3. Select the Relationships area.

  4. Select Add relationship and then select Many-to-many. This opens a panel for you to choose the table you want to create a relationship to. Select the table from the Related table drop-down.

  5. After selecting a table, the names for the relationship and relationship table will appear. They'll default with the names of the tables combined, but you can change them if needed.

    Many to Many Relationship.

  6. Select Done to add the relationship to your table, and then select Save table.

Add advanced relationship behavior

While building a one-to-many or a many-to-one relationship, you can also set advanced behaviors.

Advanced behavior.

These options are also referred to as cascading behaviors because they cascade down the hierarchy of related tables. For example, it might be desirable to delete the related tests and homework of a student if a student is removed from the system. This type of behavior is called a parental relationship.

On the other hand, you might decide that you don't want actions to cascade down the hierarchy. For example, in the teacher to class relationship you could decide that the child table (class) shouldn't* be deleted when a parent (teacher) is deleted. This is called a referential relationship.

As you model your business data by creating custom tables or when using existing Common Data Model tables, consider the behavior you require and the implications for the entire hierarchy of related tables and choose between one of the following standard behaviors:

  • Referential, Remove Link: In a referential relationship between two tables, you can navigate to any related rows, but actions taken on one won't affect the other. For example, if you have a one-to-many relationship between teachers and classes, deleting a teacher will have no impact on the related class.

  • Referential, Restrict Delete: In a referential, restrict delete relationship between two tables, you can navigate to any related rows. Actions taken on the parent row won't be applied to the child row, but the parent row can't be deleted while the child row exists. This is useful if you don't want child rows to become orphaned. This forces the user to delete all of the children before deleting the parent.

    Referential, Restrict Delete.

  • Parental: In a parental relationship between two tables, any action taken on a record of the parent table is also taken on any child table records that are related to the parent table record. For example, the owner of the parent record has inherited access to the child table records and when the parent record is deleted, all of the child records will also be deleted.

  • Custom: In a custom relationship between two tables, you select the behavior associated with each of a set of possible actions.

    Custom behavior.

For more information on defaults and custom behaviors: Configure table relationship behavior.

Use a lookup column in an app

If you create an app automatically from a table that contains a lookup column, it appears as a Drop down control that contains data from the Primary name column of the table.

Add 1:N and N:N relationships for canvas apps

Use the Relate function to link two rows through a one-to-many or many-to-many relationship in Microsoft Dataverse. More information: Relate and Unrelate functions in Power Apps

Next steps