Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using multiple tables to store your products isn't a good idea. Because there will be products that overlap in categories which would result storing the same product in more than one table. </p> <p>Just use a product table with the ID, product_number, description, etc. and a category table to store the different categories. Then you could link them directly like:</p> <p>Product table:</p> <pre><code>ID product_number description category 1 00001 Screwdriver 1 </code></pre> <p>Category table: ID description 1 Tools</p> <p>And you could even expand the category table with an extra column to use subcategories by addressing the parent of the subcategory:</p> <p>Category table with subcategories:</p> <pre><code>ID description parent 1 Tools NULL 2 Automatic tools 1 </code></pre> <p>And if you don't like directly linking to the category table from the product table you could use a link table:</p> <p>Product_category:</p> <pre><code>Product_ID Category_ID 1 1 </code></pre> <p>Hope this answers your question.</p> <p>Edit, added filter table:</p> <p>To add filtering for a product you can use a table for a the filters and a link table, like so:</p> <p>Filter:</p> <pre><code>Filter_ID description value 1 brand Bosch 2 brand Bahco 3 type Phillips </code></pre> <p>Product_Filter:</p> <pre><code>Product_ID Filter_ID 1 1 1 3 </code></pre> <p>That way you can link more than one filter to each product and use the same filter more than once.</p> <p>You could even expand this further by using another table for the filter values, but that could make things a bit to complicated:</p> <p>Filter:</p> <pre><code>Filter_ID description value 1 brand 1 </code></pre> <p>Filter_value:</p> <pre><code>Filter_ID value 1 Bosch 2 Bahco </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload