title: Create Mongoose Schema Dynamically for e-commerce website in Node
body: <p>I would like to ask a question about a possible solution for an e-commerce database design in terms of scalability and flexibility.</p>
  <p>We are going to use MongoDB and Node on the backend.</p>
  <p>I included an image for you to see what we have so far. We currently have a <strong>Products table</strong> that can be used to add a product into the system. The interesting part is that we would like to be able to add different types of products to the system with varying attributes.</p>
  <p>For example, in the admin management page, we could select a <strong>Clothes item</strong> where we should fill out a form with fields such as <em>Height, Length, Size</em> ... etc. The question is how could we model this way of structure in the database design?</p>
  <p>What we were thinking of was creating tables such as <strong>ClothesProduct</strong> and many more and respectively connect the <strong>Products table</strong> to one of these. But we could have 100 different tables for the varying product types. We would like to add a product type dynamically from the admin management. Is this possible in Mongoose? Because creating all possible fields in the <strong>Products table</strong> is not efficient and it would hit us hard for the long-term.</p>
  <p><a href="https://i.stack.imgur.com/FSW3h.png" rel="nofollow noreferrer">Database design snippet</a></p>
  <p>Maybe we should just create separate tables for each unique product type and from the front-end, we would select one of them to display the correct form?</p>
  <p>Could you please share your thoughts?</p>
  <p>Thank you!</p>