

Flattened Relationships
In addition to flattening attributes, you can also flatten relationships. Flattening a relationship gives a source entity access to relationships that a destination entity has with other entities. It's equivalent to performing a multi-table join. Note that flattening either an attribute or a relationship can result in degraded performance when the destination objects are accessed, since traversing multiple tables makes fetches slower.When Should You Use Flattened Relationships?
As discussed in When Should You Use Flattened Attributes?, flattening is a technique you should only use under certain conditions. Instead of flattening an attribute or a relationship, you can instead directly traverse the object graph, either programmatically or by using key paths. This ensures that your application has an internally consistent view of the data.Flattening a Relationship
To flatten a relationship:- Add a relationship from one entity (entity_1) to a second entity (entity_2).
For example, you can add a to-many relationship called toDirectors from Movie to Director since a movie can have more than one director.
- Add a relationship from entity_2 to a third entity (entity_3).
For example, you can add a to-one relationship called talent from Director to Talent. For each director a movie has, there is a corresponding single entry in the Talent table.
- From entity_1, select the relationship to entity_2 to display its properties.
From Movie, select the relationship toDirectors to display the properties of Director.
- In the list of properties for entity_2, select the relationship (talent) you want to flatten.
- Choose Property
Flatten Property.
Table of Contents
Next Section