How to design a m:n-Relation?

Discussion created by disabled_Luna.media on Oct 1, 2013
Latest reply on Oct 7, 2013 by jlamprecht

Hi there,


I tried hard but failed. Mabye somebody can give me a hint how to design a m:n-relation-ship between "Companies" and "Brands". I want to have a portal that shows me all brands that are assigned to a company. Brands can be assigned to different ones but shoul only exists once (unique brand name).


What I have (simplified):

  • table Companies
    • fields: ID Company, Name (should be unique)
  • table Brands
    • fields: ID Brand, Brandname (should be unique)
  • table Relations_Company_Brand
    • fields: ID Relation, ID Company, ID Brand


I have made the relations between these three tables and implemented in my Company layout portal for the table Relations_Company_Brand. I also have a field "Brandname" from the table "Brands" in the portal to show the "nice" names of the brand and not only the IDs.


Now my problem: how can I type in a brand name so that a relations is created with the ID of the company and - if the brand is existing - the ID of the brand OR a new entry in the table Brands is created and the new ID of the brand is used. Is there a trick? A light way to implement this? Any sample database?


This would help me much!

Kind regards, Luna