title: Database design for eCommerce Site with filters
body: <p>I am doing a project on eCommerce website, but I am unable to figure out, how to design the database schema for it. In this website, there will be products from several categories and each category has a unique set of filters for it. </p>
  
  <p>Example: The 'Laptop' category has filters such as 'RAM', 'Hard disk', 'Graphics Card', whereas, in the 'Shirt' category filter is 'Fabric Type' and many more.</p>
  
  <p>I have thought of 2 different schema, but I am not sure of which one to be used.</p>
  
  <p><strong>Design #1</strong></p>
  
  <pre><code>categories
  ---------
  id
  category
  filters (Here filters will be stored as hard-coded JSON)
  
  products
  --------
  id
  category_id
  name
  price
  specifications (Stored as JSON which will be filters using values from categories.filters)
  </code></pre>
  
  <p><strong>Design #2</strong></p>
  
  <pre><code>categories
  ----------
  id
  category
  table_name
  
  products
  --------
  id
  category_id
  name
  price
  
  laptops
  -------
  id
  product_id
  ram
  hard_disk
  
  shirts
  ------
  id
  product_id
  fabric
  sleeve
  </code></pre>
  
  <p>Which design should I choose? or is there any better design for it?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here, my problem is not about multiple categories but, to integrate filters. For example if I check 'RAM 4 GB' in Laptop category, then it should show all products from Laptop category with 4 GB RAM. I can't make one table for each filter, or category as there will be more than 100 of them.</p>