0 Replies Latest reply on Nov 11, 2007 2:04 PM by David Crecente

    doubts mapping serveral relations

    David Crecente Newbie

      Hi all,
      I am having problems mapping two relations among tables.
      I am using EJB3, so standard java persistence.

      1) First relation definition.
      The idea here is that a category may belongs to many categories. A many
      to many relation but with itself.

      CATEGORY
      * ID
      * DESCRIPTION
      * more properties
      
      PARENT_CATEGORY
      * CATEGORY_ID (FK) (foraign with id in table category)
      * PARENT_ID (FK) (foraign with id in table category)
      no more properties



      2) Second relation definition.
      It is a simple many to many relation between CATEGORY and LOCALE but
      the table CATEGORY_LOCALE has more properties. Mayby I might write a
      CategoryLocaleEntity with a composite primary key but this composite
      key should be a composition of id in CATEGORY and id in LOCALE.

      CATEGORY
      * ID
      * DESCRIPTION
      * more properties
      
      LOCALE
      * ID
      * more properties
      
      CATEGORY_LOCALE
      * category_id (FK) (foraign with id in table category)
      * locale_id (FK) (foraign with id in table locale)
      * more properties


      Thank you in advance.