I have a project where there is a dealer locator which is supposed to locate the dealers in the area. The dealers supply multiple brands of different items(example: cement bricks etc.).
These items have subcategories and may also have a variable length sub categories.
Under the sub categories are the brands. Brands are lowest level of that product , meaning there is no end product, all these put together is the product
These dealers have a location which is used to map them on google maps.
The locator must have filters where one can select the category and then a sub category and if exists a sub sub category . Also one can select the brand and quantity of the product.
I have tried different ways to create the database , but have failed. I am having difficulty in accessing products which have to be displayed after selecting each filter option.
My questions:
- Should I create a table for every product , if so what will be the attribute?
- How to handle the variable length sub categories ?
- How can I access each product based on category or sub category or brand.
Sample schema:
table:categories(Parent_ID | Category_ID | Category_Name);
table:product (Dealer_ID| Brand_ID|Quantity); - table for each product
table:brands(brand_ID|Category_ID|Brand_Name);
table:Dealer(dealer_ID|lat|long|name ...etc.);
When the page loads all dealers are shown in the map based on location.
On selecting each option the page reloads and displays the dealers based on the selection.
With my current schema I am unable to access them based on selection.
Wall of Text. (1) table for every product - No. (2) variable length sub categories - use columns to show parent (next level up category/subcategory). (3) access each product - using subqueries and/or joins. What would make it easier is for you to map out some sample data and then find ways to you to condense/link similar and/or sub data. - Sean