Monday, 4 July 2016

Table Inheritance In Microsoft Dynamics Ax 2012

When you consider the use of inheritance between two tables, one table is the proposed base table, and the other is the proposed derived table.

should consider the use of inheritance between two tables when all the following conditions are true:

   1) There is no thought that there might be a 1-to-many or many-to-many relationship between the two tables.

    An existing row in the proposed base table, and the corresponding row in the derived table, both refer to the same item in the real world.

    Each row in the proposed base table has exactly one corresponding row in the derived table.

    If one row is ever deleted from either table, the corresponding row must also be deleted.

    The base table probably has at least two tables that derive from it.

    The two derived tables have fields for different kinds of things.
    The two derived tables refer to different variations of the general items that are tracked together in the base table.

    No item that is represented in a base table would ever be represented in more than one of its derived tables.

    The derived table is not meant for performance tuning of the physical database, such as placing an image column in its own table.

Example:
Create a table and name it as Base table.
[Note: For a temporary table ,we cannot set the support inheritance property to YES.]

create a field with datatype int64 and name it as InstanceRelationType.

Now set the Table property Support Inheritance --> Yes

create a field with datatype int64 and name it as InstanceRelationType.
create a field  with datatype str and name it as person.
create one more field with datatype int and name it as MyID.
Now set the table properties:

InstanceRelation Type --> InstanceRelationType
Abstract --> Yes

Create a new table and name it as Derived table.

set the table properties
Support Inheritance --> Yes
extends to -->BaseTable

create one more table and name it as Derived.

set the table properties
Support Inheritance --> Yes
extends to -->BaseTable

create a field with datatype str and name it ContactNo.

Now we will get the fields automatically in the Derived table.
Links: