Usually the way this is done is to have one table that lists out all the main categories and the information about them including the ID. Then there is a table that lists out all the subcategories. Each of the subcategories would have an ID and also store the main category ID in a different column. That way there's only 2 tables rather than a table for each main category.
You would then have a Product table that would list which category or subcategory that the product was part of. So in the Product table, you'd have an ID column and a categoryID column.
The drop downs being dynamically populated would be done with the Dynamic Dropdowns product that we have:
dynamic-dropdowns/