3 Replies Latest reply: Jan 18, 2013 4:45 AM by Ben Rogers RSS

    many-to-many relationship

    Rajan.Panchal
      Hi,
      I want to understand many-to-many relationship. I have gone through the OPM help but still I am unclear on below points:
      1. If there are two many-to-many relationship between two entities then how an entity instance can become a member of a particular relationship. (Note: the many-to-many relationship is not an inferred one).
      2. what difference will it make i.e using two different many to many relationship in rules?

      I will appreciate if an example is provided.

      thanks,
        • 1. Re: many-to-many relationship
          Matt Sevin
          Each many-to-many relationship represents a different semantic relationship. For example,a person and a product may have many different "relationships" depending on the domain you are modeling and the policies you intend to express: a person's previously purchased products <=> the product's previous purchasers, the person's returned products <=> the persons whom returned a product, the person's viewed products etc. Each of these are many to many relationships between a person and a product yet each represents a different semantic relationship. i.e. each relationship means something different and that meaning will be defined, expressed and differentiated by the natural language text you choose to associate with each relationship.
          • 2. Re: many-to-many relationship
            Rajan.Panchal
            That is fine. I understand that each relationship will represent another semantic but how the entity instances will become part of the relationship? Since these are not inferred relationships we cannot make an entity instance part of any of the relationhip at runtime. For example:

            entity: the person
            entity: the product

            relationship1: the person's returned products <=> the persons who returned a product
            relationship2: a person's previously purchased products <=> the product's previous purchasers

            Assume we have two entity instances created entityInstance1, entityInstance2, Will these two entity instances be part of both the relationship?
            • 3. Re: many-to-many relationship
              Ben Rogers
              If you have a many to many between the person and the product:
              the person's returned products <=> the persons who returned a product

              ..firstly, I would personally write the reverse relationship the other way around to make your rules easier to understand:

              the person's returned products <=> the product's people that returned the product

              So, create 3 people
              person 1
              person 2
              person 3

              Create 3 products
              product 1
              product 2
              product 3

              if you say that person 1 has returned products 1 and 2
              person 2 has returned product 2
              person 3 has returned products 1, 2 and 3

              then if you check the reverse relationship (the product's people that returned the product) you will see that
              product 1 has person 1 and person 3
              product 2 has person 1, person 2 and person 3
              product 3 has person 3

              So by setting the many-to-many in one direction (i.e. from the person to the product), we can infer the reverse direction (i.e. from the product to the person).
              You could do this for yourself in the OPM debugger. Sometimes a good way to learn is to debug something and try it out...

              The help contains some useful diagrams:

              http://docs.oracle.com/html/E27987_01/Content/Data%20model/Define_a_relationship.htm

              Also an example rulebase is provided for a many to many.

              Hope this helps answer your question.
              Ben