Previous Topic: Nonidentifying RelationshipsNext Topic: Naming and Defining Entities and Attributes


Rolenames

When foreign keys migrate from the parent entity in a relationship to the child entity, they are serving two roles in the model in terms of stated business rules. To understand both roles, it is helpful to rename the migrated key to show its role in the child entity. This name assigned to a foreign key attribute is known as a rolename. A rolename declares a new attribute, whose name is intended to describe the business statement embodied by the relationship that contributes the foreign key.

TEAM and PLAYER entities with rolenames

The foreign key attribute of “player team id.team id” in the PLAYER entity shows the syntax for defining and displaying a rolename. The first half (before the period) is the rolename. The second half is the original name of the foreign key, sometimes known as the base name.

Once assigned to a foreign key, a rolename migrates across a relationship similar to any other foreign key. For example, suppose that you extend the example to show which PLAYERs have scored in various games throughout the season. The “player team id” rolename migrates to the SCORING PLAY entity (with any other primary key attributes in the parent entity), as shown here:

TEAM, PLAYER, and SCORING PLAY entities with rolenames assigned

Note: A rolename is also used to model compatibility with legacy data models where the foreign key often had a different name from the primary key.