Hi guys,

Hope i'm putting this in the right place. Apologies if i'm not!

I'm making a website for a sports suppliments supplier. I'm having some trouble with how to layout the database.

I have a navigation menu which has all the categories listed. But some of my products are listed in multiple categories. I can't figure out how to layout my database.

I have in table products:

Product_ID, Category_ID, Product_Name, Product_Description

And in table categories I have:

Category_ID, Category

How do I go about putting a product into multiple Categories?

Thanks guys!

Recommended Answers

All 2 Replies

You've to make another table ProductCategories containing:
CategoryID, ProductID

And table product should contain:
ProductID, Product_Name, Product_Description

table categories is the same:
Category_ID, Category

In your version of the products table there is functional dependency, so you have to normalise it.. Hope this will help you

Finally got to do as you said and it now works perfectly.

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.