in

The ORM Foundation

Get the facts!

Relation mapping of subtypes

Last post 01-28-2013 20:52 by Matthew Curland. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 01-28-2013 16:37

    • jacobvos
    • Top 50 Contributor
      Male
    • Joined on 01-21-2013
    • The Netherlands
    • Posts 16

    Relation mapping of subtypes

    Let's take as starting point the following simple model:

    - Entity type 'Party'
    - Entity type 'Partner', subtype of 'Party
    - Entity type 'Customer', subtype of 'Party'
    - Entity type 'Consumer', subtype of 'Customer'
    - Entity type 'Business customer', subtype of 'Customer'

    When making a relational mapping, I have one entity type 'Party'. That's OK.

    Now I would expect in the entity type 'Party' a way to indicate what kind of party it is.

    What is my wrong reasoning?

    Do I have to add to the ORM model a fact type 'Party is of Party_Type' (with possible values of 'Party_Type': Partner, Consumer, Business customer)?

    Jacob

  • 01-28-2013 20:52 In reply to

    Re: Relation mapping of subtypes

    Answer

    Hi Jacob,

    You're not missing anything. Single-table relational mapping with asserted subtypes that play no other roles is an undone in NORMA. The only way to generate this data right now is to push the asserted subtypes into a separate table. This can be done by choosing the subtype connector and setting the Relational Mapping AbsorptionChoice property to 'Not Absorbed' (selecting the subtype and setting the AbsorptionChoice to 'Separate' is an equivalent action).

    The general solution to this problem is far from trivial because 'isSubtype' column falls into one of three categories:

    • If the subtype plays no other roles, this is an asserted boolean column.
    • If the subtype plays no mandatory roles, then the column is semi-derived (derivably true if any roles are played, asserted if no roles are played).
    • If the subtype plays at least one mandatory role then the column is fully derived. However, the derivation may not be trivial because the mandatory role may be expressed outside the current table.

    In most models, subtypes will actually play additional roles. In fact, Terry recommends not creating subtypes if they subtype plays no additional roles. The end result is that as the model matures, in practice you get very few subtypes with no role players.

    If you find that you have a large subtype tree where the subtypes play no roles, you may want to consider a PartyType style fact type on the supertype.

    The NORMA RMAP is still relatively basic. This is one area that those funding NORMA-related development have had little interest in for the past few years, but that is rapidly changing, so Terry (SQL guru) and I will be spending more time on this area in the next year.

    -Matt

     

Page 1 of 1 (2 items)
© 2008-2013 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service