Multiple categories

A

Anita

Hi

I have a database that I need to design of a list of
websites that would then be put into categories. My
problem is that 1 website could be put into multiple
categories and I don't know how to do this without
creating multiple tables

Thank you for any help you can give me.
 
A

Allen Browne

You have a many-to-many relationship between categories and websites. You
resolve that with a junction table.

tblCategory:
CategoryID primary key
CategoryName

tblWebsite:
WebSiteID primary key
Website

tblWebSiteCategory:
WebSiteID foreign key to tblWebsite.WebSiteID
CateogryID foreign key to tblCategory.CategoryID
 
G

Guest

Thank you for this, but could I make it a bit more
complicated? I have 2 main categories with sub
categories which I have made into 2 separate tables, the
websites can be categorised into the 2 main categories and
then they can be categorised again into multiple sub
categories. What would be the best way of doing this?

Many thanks again for this.
 
A

Allen Browne

Combine the 2 category tables into one, with an additional field to tell
them apart.

You can then select them as needed in your queries, but it doesn't come into
the issue we were discussing. It's like every one of your existing
categories is a member of one of the super-categories.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top