Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Categories

Author  Topic 

chazmonro
Starting Member

2 Posts

Posted - 2005-08-05 : 08:50:43
I don't know exactly how to explain this so here goes, it might be a long one.

I'm building a website that has 3 Market Categories. Below each Market is a Master Category, and below that is a General Category.

Anyway, for each Product that exists below the General Category level it needs a table that associates that Product with a General Category, a Master Category, and a Market Category. A product can belong to any or all of each category, Thus I have built tables to associate a product with each cateogry. This is what it looks like in the database.

TABLE_PRODUCTS
TABLE_PRODUCTS_GENERAL_CATEGORIES
TABLE_PRODUCTS_MASTER_CATEGORIES
TABLE_PRODUCTS_MARKET_CATEGORIES

This is the way I have built data structures before in the past, however the more categories that there are, the more and more tables that need to be created. I'm wondering if there is a better way to do this?

Does my question make sense to anyone?

Chuck

Kristen
Test

22859 Posts

Posted - 2005-08-05 : 09:19:26
Hi chazmonro, Welcome to SQL Team!

How about a Category table that has columns for:

[Kind] - General / Master or Market
[Category]
[Product]

or maybe I'm missing the plot!

Kristen
Go to Top of Page

Stalker
Yak Posting Veteran

80 Posts

Posted - 2005-08-05 : 09:21:05
so, there are several categories and there are products which can fall to any number of these categories ?

It make sense to create table Categories(CategoryID int,NameOfCategory varchar(50)) and table Products(ProductID int, NameOfProduct varchar(50)).
Now you can link them together by creating table Links(ProductID int,CategoryID int). This table can hold one or more rows about the same product

Is it what you need ?
Go to Top of Page

chazmonro
Starting Member

2 Posts

Posted - 2005-08-05 : 11:15:47
Thanks guys, you're both onto something. I wish I would have posted this question about a month ago, it might have saved me some time.

Anyway, I appreciated the help. I'm still a newbie at this SQL stuff.

Chuck
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-05 : 11:40:30
I can sell you a time machine cheap, if you are interested?

Kristen
Go to Top of Page
   

- Advertisement -