Table Relation Properties

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

This topic describes the property of a table relation in the Application Object Tree (AOT). In the AOT, table relation nodes are located under the child table that has the foreign key field. The specific location is under the following node:

AOT > Data Dictionary > Tables > MyTable > Relations.

The related primary key or alternate key field is in the referenced table, which is also called the parent table.

List of Properties

The following table describes the properties for a table relation in the AOT.

Property

Description

New in this version of
 Microsoft Dynamics AX

Cardinality

The number of times that each primary key value from the referenced table must occur in the foreign key column of the present table.

For example, the value OneMore means one or more, but not zero. It means that every parent key value must occur in the child table’s foreign key column at least one time. A relation node under a SalesLine table could use the OneMore value when the business rule requires that every record in the parent SalesTable table relate to at least one item that is being sold.

In Microsoft Dynamics AX 2012 this property is not yet used by the system. Future releases of the product can potentially use this property, and the RelatedTableCardinality property.

Microsoft Dynamics AX 2012

CreateNavigationPropertyMethods

Yes directs the system to generate navigation methods on the table buffer class for each foreign key relation node.

For more information about navigation methods, see the section CreateNavigationPropertyMethods and RelatedTableRole.

Microsoft Dynamics AX 2012

EDTRelation

Yes means this relation was migrated to here from an old extended data type (EDT) relation, by a software tool.

Microsoft Dynamics AX 2012

EntityRelationshipRole

The EntityRelationshipRole property is used to clarify the semantics of a relationship defined on a table. A role name should be either a noun or a noun phrase. The role name should indicate the role of the associated table in relation to the associating object, or it should be a short phrase that starts with a present-tense verb that indicates the role that the table plays in the relationship. Role names are not required when the relationship is unambiguous.

Model

The model that this relation is a part of.

Microsoft Dynamics AX 2012

Name

A descriptive name that you choose for the relation.

NavigationPropertyMethodNameOverride

Specifies the name for the navigation method. If no value is specified, the navigation method uses the value from the RelatedTableRole property.

For more information about navigation methods, see the section CreateNavigationPropertyMethods and RelatedTableRole.

Microsoft Dynamics AX 2012

RelatedTableCardinality

Specifies whether the foreign key field value in the current table can be null in some or all records of the current table. The possible values are the following:

  1. ZeroOne – means zero or one. This means the foreign key field in a child record can be null.

  2. ExactlyOne – means the foreign key field cannot be null in any child record.

Microsoft Dynamics AX 2012

RelatedTableRole

A text value that you type to describe the purpose of the referenced parent table in this relationship. When a table has only one relation that references a given parent table, you can use the name of the parent table. Sometimes a table has more than one relation to a given referenced parent table. In such cases the RelatedTableRole property value should describe the relation well enough to distinguish the relation’s purpose from the other relation to the same parent table.

The value of this property can be used as the value of the JoinRelation property of a data source relation under an AOT query. In standard cases, this usage is recommended because it reduces denormalization.

This property interacts with the UseDefaultRoleNames property.

For more information about the interaction between the RelatedTableRole and JoinRelation properties, see RelatedTableRole and Query JoinRelation.

Microsoft Dynamics AX 2012

RelationshipType

You select a value that describes the subtle relationship between two tables.

For example, the value Composition means that the child record cannot meaningfully exist without being related to a specific parent record. The record for the fourth floor in the Floor table cannot exist without referencing a record in the parent Building table.

Note

The DeleteActions should be compatible with this property setting. For a Composition relationship, the DeleteActions should include delete cascade behavior.

For more information about delete actions, see How to: Create Delete Actions.

For more information about the available values for this property, see Understanding the RelationshipType Enumeration or RelationshipType.

In Microsoft Dynamics AX 2012 this property is not yet used by the system. A future release of this product can potentially use this property.

Microsoft Dynamics AX 2012

Role

A name that describes the meaning or role of the relation. For example, one relation to a Department table could track the department that the employee currently belongs to. Meanwhile another relation could track the department that the employee has requested transfer to. Both are relations to the Department table, but the two relations are filling different roles.

In practice, a fine value is often the names of the child and parent tables conjoined by an underbar _ character. For example, SalesTable_SalesLine.

This property interacts with the UseDefaultRoleNames property.

Microsoft Dynamics AX 2012

Table

The table that the relation refers to.

UseDefaultRoleNames

Yes means that the system must generate default values for the Role and RelatedTableRole properties.

Even when set to Yes, the generated values for Role and RelatedTableRole do not appear in the Properties window. Also, the TreeNode class does not use the generate values. However, the reflection class DictRelation does use the generated values.

Microsoft Dynamics AX 2012

Validate

Yes means that each insert of a record by a form into the child table is rejected unless the related record exists in the referenced parent table. Also, the delete of a record by a form from the parent table is either rejected or the delete cascades to the related records in the child table.

You use No when the RelationshipType property is Link. You might also use No in special temporary cases, such as during some upgrade scenarios. When the value is set back to Yes, no validation occurs for records that were inserted or deleted while the value was No.

Warning

A value of Yes for the Validate property does not prevent direct X++ SQL data operations from deleting parent records or inserting child records that violate the integrity of foreign key data.

Note


When both tables have their SaveDataPerCompany property set to Yes, the system adds the DataAreaId field to each relationship.

RelatedTableRole and Query JoinRelation

This section describes how you can use the RelatedTableRole property to simplify the creation of a new query.

Suppose that on a table relation you enter an explicit value for the RelatedTableRole property. You can then use that value to populate the JoinRelation property on a data source relation under an AOT > Queries > MyQuery node. This enables you to specify the fields of the join in only one location. If the join fields ever change, you must update the join in only one location.

Before you can set a value for the JoinRelation property, you must delete the values for the Field and RelatedField properties.

The following two images show how to use the JoinRelation property.

  1. First image - shows the properties on a table relation, and the value of the RelatedTableRole property is highlighted.

  2. Second image - shows the properties on a data source relation under a query. We see that the value for the JoinRelation property is a copy of the value for the RelatedTableRole.

RelatedTableRole property on a table relation.

The RelatedTableRole property on a table relation

In the next image we see the value for the JoinRelation property is a copy of the value for the RelatedTableRole from the previous image.

The JoinRelation property on a query relation

The JoinRelation property on a relation under a query

CreateNavigationPropertyMethods and RelatedTableRole

When you set the CreateNavigationPropertyMethods property to Yes on a table relation, the system generates navigation methods for the table buffer class. A navigation method links two table buffer instances by their foreign key relationship. The UnitOfWork class is one area where this navigation linkage is used.

The name for a navigation method is copied from the value of the RelatedTableRole property on the table relation. This is true when the RelatedTableRole value is set explicitly in the Properties window, and when the RelatedTableRole value is generated by setting the UseDefaultRoleNames to Yes.

The property values in the previous images generate the following navigation method on the child CustTable buffer. Most directly, the navigation method name is copied from the value of the RelatedTableRole property:

public final CustBankAccount BankAccounts([CustBankAccount relatedTable])

The following list describes cases where you must override the name that the system generates for a navigation method on a table buffer class:

  • The table class already has a method name that matches the RelatedTableRole property value.

  • The RelatedTableRole property value is longer than the maximum length enabled for a method name.

In these cases you must choose a valid name for the navigation method, and assign that name as the value for the NavigationPropertyMethodNameOverride property, on the table relation.

See also

Table Properties