Understanding relationships – Identify the core components of Power Platform

Share this post on:
Understanding relationships

Depending on the nature of the app a developer is creating and the data that it will use, it might be a good idea to create multiple entities to hold different types of data, rather than store many different data types in a single entity.

For example, in the case of an order entry app, the developer might need to maintain a list of incoming invoices and a list of the products ordered on each invoice. The database for this app would therefore need—at minimum—records for the invoices and records for the products ordered. There would presumably also need to be records for customer information and records for an inventory of products. Storing all of this information in a single entity (or table) would be complicated at best.

To better organize the data for the app, it would therefore be preferable to create multiple entities and establish relationships between them. If the developer creates separate entities for the invoices and the products ordered, there could be said to be a one-to-many (also called a parent/child or 1:N) relationship between the two entities. The invoice entity would be the one (or the parent), and the products entity could contain as many product records (or children) as are needed for each invoice.

In the same way, the invoice entity can have a many-to-one (N:1) relationship to an entity containing customer information. Each customer can have many invoices, but each invoice is associated with only one customer. This type of entity relationship appears as a field type called a lookup field.

Common Data Service also supports many-to-many (or N:N) relationships between entities, in which many records in one entity are associated with many records in another entity, in what are known as peer relationships.

As mentioned earlier, the standard entities provided by Common Data Service are sufficient for the needs of most developers and their apps, and the relationships between the entities are already in place. Selecting any entity in the Power Apps portal and selecting the Relationships tab displays the existing relationships and their types, as shown in Figure 2-6.

FIGURE 2-6 The Relationships tab for the Customers entity in the Power Apps portal

From this screen, it is also possible for developers to create new relationships by clicking the +Add relationship button and choosing Many-to-one, One-to-many, or Many-to-many, to open a dialog box like the one shown in Figure 2-7.

FIGURE 2-7 The One-to-many dialog box in the Power Apps portal

Share this post on:

Leave a Reply

Your email address will not be published. Required fields are marked *