title: Database design - Multiple objecttypes shown hierarcial?
body: <p>I have been struggling and searching for a solution about this for a couple of days but i cannot find any "best practices" or good explanations of how to achive what i want.</p>
  
  <p>Lets say that I have a database consisting of the following tables (just an example);</p>
  
  <pre><code>Customers (Fields: Id, CustomerName, Location)
  
  Products (Fields: Id, ProductName, ProductCode)
  
  Groups (Fields: Id, GroupName)
  </code></pre>
  
  <p>I then need to link these together to be shown in a Treeview. For example;</p>
  
  <pre><code>Customer1
      |
      |-Group1
      |    |-Product1
      |    |-Product2
      |
      |-Group2
           |-Product2
           |-Product3
           |-Group3
                |
                |-Product1
                |-Product4
  </code></pre>
  
  <p>As i said, this is just an example. The real solution consists of other types.</p>
  
  <p>Since the products can occur in several places i need to create a "link table"
  to display the hierarchial data.</p>
  
  <p>So i created another table looking like this;</p>
  
  <pre><code>Id (int)
  ParentId (int)
  ObjectType (int)
  GroupId (int)
  ProductId (int)
  CustomerId (int)
  </code></pre>
  
  <p>The reason for the ObjectType field is to know in what database i need to check for the items name etc. to display in the treeview.</p>
  
  <p>My question now: Is there any other way to design this database?
  I am developing in C# using LINQ etc.</p>