Re: Abstract Entities [Was: Modelling improvements: inheritance + interfacing (Draft)]

From: Aristedes Maniatis (ar..aniatis.org)
Date: Thu May 31 2007 - 01:09:30 EDT

  • Next message: srinivas sagar: "Re: Abstract Entities [Was: Modelling improvements: inheritance + interfacing (Draft)]"

    On 31/05/2007, at 1:03 PM, Craig L Russell wrote:

    > While it might be possible theoretically to define a different
    > column in the database to be used as the association column to join
    > rows of a subclass and a superclass table, by far the most common
    > and most understandable way to map inheritance is to simply assume
    > that the primary key of both tables is the same and that the id
    > field in the class contains the value to be used for both primary
    > keys. The direction of the foreign key constraint should indicate
    > which is the subclass.

    Yes, 99% of the time this is correct. However, if we want to support
    compound primary keys there is a need to describe how the columns in
    the subclass map to the columns in the superclass. That way Cayenne
    can populate them both correctly. Our original plan was to use an
    object relationship description in the DataMap to describe this
    pairing. The alternative is to use the names of the object attributes
    in order to match the primary key columns to each other, but
    something about this bothers me as an approach.

    Also, as Lachlan points out, this means that we don't get to specific
    nullify, cascade, etc delete rules. If you have a concrete
    superclass, you may wish to nullify the relationship when deleting
    the subclass record. Naturally if the superclass is abstract this is
    not allowed. But specifying the objrelationship explicitly allows us
    to put these rules somewhere and remove any ambiguity from compound
    key relationships.

    Ari

    -------------------------->
    Aristedes Maniatis
    phone +61 2 9660 9700
    PGP fingerprint 08 57 20 4B 80 69 59 E2 A9 BF 2D 48 C2 20 0C C8





    This archive was generated by hypermail 2.0.0 : Thu May 31 2007 - 01:10:16 EDT