Re: Entity Attribute Value model with Cayenne?

From: Aristedes Maniatis (ar..aniatis.org)
Date: Mon Aug 23 2010 - 23:03:48 UTC

  • Next message: Victor Antonovich: "Queries against to-many relationships with 'NOT' subexpressions"

    On 24/08/10 1:06 AM, Robert Zeigler wrote:
    > Main Entity -> Map relationship of value entities. Each value entity has a to-one relationship to the attribute descriptor table.
    > One thing you might consider doing in your attribute descriptor table is to make the "type" be a java enum;

    There is (was?) an issue in Cayenne with using enum as an entity discriminator (that it, as the way to create Cayenne inheritance). So if your model ends up with inheritance based on this field, make sure it is string or int.

    So, say you have this db structure:

    Attribute
      - id
      - name

    AttributeValue
      - attribute_id
      - value
      - entity

    Then you could map that with inheritance like this:

    AttributeValue (superclass)
      attr: attribute_id
      attr: value
      attr: entity (used as discriminator)

    PaintingAttributeValue (subclass)
      relation:-> Painting

    ArtistAttributeValue (subclass)
      relation: -> Artist

    Naturally you'd add to your Attribute table all sorts of validation definitions. You might want to restrict values to be numerical (but you are still storing them in the db as blob or string). Or restrict the entry length.

    Cheers

    Ari

    -- 
    -------------------------->
    Aristedes Maniatis
    GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
    



    This archive was generated by hypermail 2.0.0 : Mon Aug 23 2010 - 23:04:26 UTC