web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Table inheritance

(1) ShareShare
ReportReport
Posted on by 3,542

I have a few questions/issues. I have googled and read a lot. I would've found the solutions by trial and error, but using this functionality has an enormous impact on the server I'm using. It will take ages and too much frustration to try different methods. Hence the first issue.

1. From the point where I change the table property Supports Inheritance to Yes any development related to the table takes a significant performance hit. Adding a field to the table or changing a property takes seconds. This snowballs further for form datasources of the table type - it takes minutes and sometimes never to change some property. We have our own servers and yes they aren't the best, but everything except this works fine and reasonably quickly.

2. Abstract. Paraphrasing https://msdn.microsoft.com/en-us/library/gg881064.aspx "Abstract no - derived tables do not necessarily have a corresponding record of the base table."  Not very helpful. I assume that Abstract No means the table exists in the database and Abstract Yes means the table does not. An abstract table cannot contain records, meaning a record must be defined as a descendant and a normal base table can have a record that exists without any descendants.

3. Duplicate fields. I learned the hard way that it creates issues if different descendants have the same field name. But this is sometimes necessary. I mean a base table Animal should not have a field Wings,  but both derived tables Duck  and Ostrich should have the field. Unless you want to build the whole animal kingdom, which no-one has time for. Is it allowed or not? VS didn't prohibit me from creating the fields on table level, but still - the errors.

4. Modified By, Modified Date. Also applies to Created By and Created Date. I want to store the modifications. So I set the properties to Yes on the base table and didn't bother on the descendants, in other words they are still No. Is that correct?

5. Foreign keys. My abstract base table B has a foreign key relation to some table F. B has descendants T and U. I have a details master form where I want to display T and U separately. Table F is the root datasource. I want to skip the dialog where you select the table type to insert. So I dragged table T and U onto the form and set Join Source to F. The errors were more than biblical Israelites. For example table T has a real field. The form displays table F's RecId in the real field. Should this have worked correctly or am I supposed to link the datasource in form code?

I apologise for the essay.

Thanks for reading

*This post is locked for comments

I have the same question (0)
  • Pete Alberts Profile Picture
    3,542 on at

    6. May a derived table have zero fields? What I'm trying to accomplish: Abstract base table B has descendants C and D which each have 2 extra fields. In other words an element B can be either an element C or D. But there is a third option: An element B can also be a list. So I created another descendant E and E_list with zeroMore foreign key relation to E.

    An element B should not exist by itself - hence abstract. So E_list cannot reference B. It should reference a descendant of B. But E doesn't really have any logically applicable fields like C and D. I added an extra Description field to E to prevent any possible errors. But B already has a description field, so it shouldn't be there.

  • Verified answer
    Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    Let me react to some points. By the way, when you say you got an error, it would help if you said what error it was.

    2. Yes, the meaning is the same as in OOP. 'Abstract' means that the table isn't intended to have instances; you need a non-abstract child to create an instance.

    4. There is just a single record in DB with one set of ModifiedBy, ModifiedDateTime (etc.) fields, therefore setting it up several times wouldn't be useful.

    6. Yes, I don't see any reason why it would have to add any fields. But I don't understand what you're trying to achieve and your explanations sounds suspicious to me. If B may be something else than B (B != list of B), does the whole design make sense?

  • Pete Alberts Profile Picture
    3,542 on at

    Thank you very much Martin, much appreciated.

    2,4: Thanks for the confirmation

    5: This is my main issue. Let me try to put it straight forward:

    SCENARIO

    Parent table P exists. Abstract table B is a child of P by RefRecID. Table D is a concrete descendant of B.

    QUESTION

    If I add table P and table D to a form and join D to B (with the FornDataSource property Join Source), should it work (as it does with "normal" tables)?

    6: I'm still working on that commission add-on. So for a commission policy the user may add the following types: Constants, Variables (worker salary), Datasets (transaction revenue), Equations, Grid (in order to simulate excel INDEX and MATCH functions exceljet.net/index-and-match ). All five of the types are elements and should have a unique name. So I have a abstract base table XYZElement with significant fields CommissionPolicyRefRec and ElementName (Unique Index). And then descendant tables Constants, Variables, Datsets, Equations have the applicable extra fields.

    The grid descendant is the one I was referring to. If we ignore the mentioned hierarchy at first: A grid would be defined by two tables XYZGrid with fields CommissionPolicyRefRec & GridName and then child XYZGridLines with fields ReferenceString and lookupValue. Then it seems clear to me that XYZPolicyGrid should be a descendant of XYZElement - but then it has zero fields.

    Does that make sense or would you do it differently?

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    Re 5.:

    I assume that "B is a child of P by RefRecID" actualy means that "B is related to of P" and there is no parent-child relationsip, right? Otherwise I have no idea what you mean by inheritance "by RefRecID".

    If so, the relation should work. Simply try it to be 100% sure.

    Re: 6:

    I'm sorry, but I know too little about the domain you're trying to model to comment on your model.

    By the way, I would assume again that XYZGridLines is actually a separate table and not 'a child'.

  • Pete Alberts Profile Picture
    3,542 on at

    I guess I was using the wrong terminology. I mean child as in SalesTable and SalesLine.

    Last try and then I'll leave it.

     

    Table P : CommissionPolicy

    Field Value
    RecId 00015
    Name TestPolicy

    No relations

    Unique Index: Name

    Table B : CommissionPolicyElement (Abstract)

    Field  
    CommissionPolicy (abstract)
    ElementName (abstract)

    (InstanceRelationshipType is obviously there as well)

    Relation: CommissionPolicyElement.CommissionPolicy == CommissionPolicy.RecId

    Unique Index: CommissionPolicy && ElementName

    Table D: CommissionPolicyElementConstant (Extends CommissionPolicyElement)

    Field  Table Value
    CommissionPolicy CommissionPolicyElement 00015
    ElementName CommissionPolicyElement Const_1
    Value This 3

    Relation: CommissionPolicyElementConstant.RecId == CommissionPolicyElement.RecId

    No index

    FORM F: CommissionPolicyDetails

    Datasource Datasource table Joined To
    CommissionPolicy CommissionPolicy
    CommissionPolicyElementConstant CommissionPolicyElementConstant CommissionPolicy

    This yields unexpected results. If you initialise a CommissionPolicyElementConstant record the form displays CommissionPolicy.RecId value in the CommissionPolicyElementConstant.Value field. And when you write to table I got an error which I can't remember. (working on something else at the moment).

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    What's the point of the relation CommissionPolicyElementConstant.RecId == CommissionPolicyElement.RecId? If CommissionPolicyElementConstant extends CommissionPolicyElement, CommissionPolicyElementConstant is a CommissionPolicyElement and it's a single record in database with a single RecId.

    You said: "If you initialise a CommissionPolicyElementConstant record the form displays CommissionPolicy.RecId value in the CommissionPolicyElementConstant." How did you initialize and what value do you expect there? Unfortunately your description doesn't cover these topics.

    OK, update this thread when you learn what error you're getting.

  • Verified answer
    Pete Alberts Profile Picture
    3,542 on at

    After months and months of testing, here are my conclusions:

    1. Screwed - hailing from Africa.

    2. I was wrong. It seems as if an abstract table indeed does store records - open AgreementHeader Table Browser for reference. I guess the difference is only and strictly only that for an abstract table InstanceRelationType may not be zero - it must reference a descendant.

    3. Yes, don't do that.

    4. Martin answered.

    5. Forms do not pick up the FK relation on the base table. You need to specify it through code or use a pre-built query as datasource.

    6. Yes it may.

    a. Martin your question on my RecId relation in the inheritance hierarchy - it's standard AX :P (I still think you know everything.......except that :) )

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans