Hi
I have a product table:
Product Id, Product Description
A Category table:
Category ID, Category Description
A product can belong to many categories and a category can contain many products.
So I also have a Category/Product table that lists all products and their categories
e.g.
data:
[
{
"CategoryID": 1,
"CategoryName": "Milk, Cheese & Yogurt",
"Product": 5000,
"ProductDescription": "Semi Skimmed Milk 1ltr"
},
{
"CategoryID": 2,
"CategoryName": "Tea, Coffee & Soft Drinks",
"Product": 5000,
"ProductDescription": "Semi Skimmed Milk 1ltr"
},
{
"CategoryID": 2,
"CategoryName": "Tea, Coffee & Soft Drinks",
"Product": 6000,
"ProductDescription": "Innocent Smoothie Strawberries & Bananas 750ml"
},
etc
To manage this relationship I want to display the current list of products grouped by category.
I have a table set up displaying these items grouped by Category and all is fine, I now want to allow the user to add a new product to a category. The first question, is this an appropriate solution or is the hierarchical functionality or the parent/foreign key functionality more appropriate than grouping - the document is great, but I cannot work out which is the most appropriate way to display this related data?
I now have some queries when it comes to editing.
I want the user to be able to enter a new category based on a category in the Category table, not limited to a category currently in the category/product table. Likewise, the product should be selected from a product in the product table. Is there a way to use a dropdown list populated from a second data source (i.e. the category and product tables)?
Finally ( I know I am asking a lot of questions here!), is it possible to have a "add' button at the bottom of each category, so I already know where a new products should be added (I would include all categories from the category table with empty rows where no product is in that category). This is icing on the cake, but if it can be easily done, then I would be keen to include in the app.
I would appreciate any advice.
Thank you
Kevin