View Full Version : attribute linkage problems...


minhas_amar
09-21-2005, 09:50 AM
hello...

I need a little help in making a small database, I have made the tables already but the hard part is the relation

LINK: www.sunalpina.com/test.mdb

well the thing is that I need to make a database for tables "Product", "Category", "Admin", well the problem is between the tables "Product", "Category".

I want to make a category example "food" and in that category I want to make a sub-category "italian", "japanese"

and in the category "italian", I place product "pizza"
and in the category "japanese", I place product "noodles"

I don't know how to place the sub-category relationship in the database...

could someone please help....

ScottGem
09-21-2005, 09:59 AM
If the subcategory is only attributable to the category, then assign the product to the subcategory. You can then derive the category from the subcategory.

So you have tables like

tluCategory
CategoryID (PK Autonumber)
Category

tluSubCategory
SubCategoryID (PK Autonumber
SubCategory
CategoryID (FK)

In your Products table have a Foreign key for SubCategoryID. To get the Category, join the Products to tluSubcategory on SubCategoryID and from tluSubCategory to tluCategory on CategoryID.

minhas_amar
09-21-2005, 10:11 AM
thanks for such a quick reply..

but you should know I am abit new in access to let me try this out, if I have an problems, hope you could help...

also maybe off topic (sorry), but i want to use asp and want to pull the categories in a combo box example

If I need to add a new product and to choose its category there is a combo pull-down menu and the structure is like the one below...

- Food
- Italian
- Japanese


do you know how to get make this combo box with data read from the database.


EDIT: I am having a difficult time changing the database because of the existing relations

minhas_amar
09-21-2005, 08:14 PM
well I jus realized that the category and sub-category table you mention will be nice

BUT WHAT IF, I have "Root Category" >> "Sub-Category" >> "Sub sub catergory"

then would this relation still hold ?