locked
table-per-type inheritance & association (navigation) property RRS feed

  • Question

  • Hi all,

    I’m trying to accomplish something simple with table-per-type inheritance.


    I have followed your example on the CHM with the department as base class, and music-department as derived type.

    The base type holds the key (ID) of the department while the derived type has no key since it inherit one from the base.


    Now, if music-department is to hold an association for another type, let’s say building complex, how can one associate the association property if there is no key for the derived type?


    To make things more clear: my derived type cannot have an association because the association binding must have a referral key. How can that be accomplished?

     

    Thank you,

    Menny

    Sunday, January 13, 2008 5:42 PM

Answers

  • Your derived type certainly has a key, it's just inherited. If you create an assocaition between music-department and building-complex, and then look at the mapping for you, you'll see entries in the mapping UI for mapping between the ID of department and the ID of building-complex. Let's say that music_dept_table has a column called buildingComplexId, and that the PK of music_dept_table is "ID". Then the mapping would be:

     

    Map association to table music_dept_table

    music-department

       ID <--> ID

    building-complex

       ID <--> buildingComplexId

     

    HTH,

     Noam

    Monday, January 14, 2008 6:43 PM

All replies

  • Your derived type certainly has a key, it's just inherited. If you create an assocaition between music-department and building-complex, and then look at the mapping for you, you'll see entries in the mapping UI for mapping between the ID of department and the ID of building-complex. Let's say that music_dept_table has a column called buildingComplexId, and that the PK of music_dept_table is "ID". Then the mapping would be:

     

    Map association to table music_dept_table

    music-department

       ID <--> ID

    building-complex

       ID <--> buildingComplexId

     

    HTH,

     Noam

    Monday, January 14, 2008 6:43 PM
  • hi Noam

    what you explained is exactly what i had, but i found the problem:
    since all my association done manually, whenever i updated (add new table or just update the existing ones) the xml where subject to change in a manner that foreign keys where retrieved.
    these foreign keys caused all the hustle.

    some other associated problems where the condition values:
    1. If the DB had a tinyint field and the condition value was "1", then it would be translated (when updating) to hex value which cause inconsistency to DB
    2. if you specify a query for fetching, than that query would get erase when updating

    maybe it would be a good practice enabling the user to UNCHECK the "update" node when updating\adding to the model

    thank you,
    Menny

    Tuesday, January 15, 2008 12:49 PM