3 Replies Latest reply on Jul 24, 2002 11:55 AM by Sreekanth

    Relation-table Mapping

    Sreekanth Newbie

      I have a many-many relationship using Relation-table Mapping. And this mapping table is already existing in DB.
      Some more fields in this table need to be persisted apart from mapping fields.
      How can I insert new records into this mapping table.
      thanks

        • 1. Re: Relation-table Mapping
          Dain Sundstrom Master

          Remove the many to many relationship, and create a new bean with a one-many relationship with each of the other beans. Then add your new cmp fiels.

          • 2. Re: Relation-table Mapping
            Sreekanth Newbie

            I tried with one to many . But the problem is
            the foreign key in the intermediate mapping table is a primary key in the other table, which is not possible in 1-N relations.
            Ex:

            let's say we have two tables, Organization and Personnel. Organization's have organization_id as PK and Personnel has employee_id as PKs.
            Iam trying to have a many-many relation between these two tables. So I introduced a mapping table org-pers with a primary key consists of both organization_id and personnel_id. This table has some more fields.
            As organization_id (foreign key) in this org-pers table is a primary key of organization table , I can't have a 1-N relation between organization and org-pers tables. Similary org-pers and Personnel.
            Am I looking the problem in a right way or you mean something else ?
            thanks for ur help
            sreek

            • 3. Re: Relation-table Mapping
              Sreekanth Newbie

              I tried and the problem is this:
              The foreign key of the mapping table is a primary key in the other tablem which is not possible in 1-N relation.

              Ex:

              let's say we have two tables, Organization and Personnel.
              Organization has organization_id as PK and Personnel has employee_id as PKs.
              To have a many-many relation between these tables , I introduced a mapping table org-pers with
              a primary key consists of both organization_id and perosonnel_id. This table also has some other fields.
              Now Iam trying to create a 1-N between organization , org-pers and peronnel, org-pers.
              As organization_id is a foreign key in org-pers and it's a primary key in organization, I can not get a 1-N relation betwen organization and org-pers.
              Similarly personnel and org-pers.
              Am I looking the problem in right war or you mean something else.
              thanks for the help,
              sreek