dragonwell
Programmer
This is probably a "Modeling 101" question, but it seems to have me stumped at the moment.
My question regards a multi-level heirarchy in a configuration system. At the bottom of the chain is a "Product" entity. The Product can be in 1 or more "Category" objects. Furthermore, each Category can be in one or more "Store" objects. The twist is, I must be able to place one or more Products in each Category-Store instance.
Starting with the StoreCategory relation, I have a simple many-to-many joining table
StoreCategory
StoreID
CategoryID
Now to be able to place the products in each of those instances, I have a ProductCategory table
ProductCategory
ProductID
CategoryID
StoreID
What bothers me is that now I have created the relationship between Store and Category twice which creates redundant data. If I give the StoreCategory table a surrogate key as in
StoreCategory
StoreCategoryID
StoreID
CategoryID
could I use that in the ProductCateogry table in place of the StoreID and CategoryID columns?
ProductCategory
ProductID
StoreCategoryID
I'm not sure I like that either.
Can someone help me see where I'm wrong with these relationships?
Thanks in advance.
My question regards a multi-level heirarchy in a configuration system. At the bottom of the chain is a "Product" entity. The Product can be in 1 or more "Category" objects. Furthermore, each Category can be in one or more "Store" objects. The twist is, I must be able to place one or more Products in each Category-Store instance.
Starting with the StoreCategory relation, I have a simple many-to-many joining table
StoreCategory
StoreID
CategoryID
Now to be able to place the products in each of those instances, I have a ProductCategory table
ProductCategory
ProductID
CategoryID
StoreID
What bothers me is that now I have created the relationship between Store and Category twice which creates redundant data. If I give the StoreCategory table a surrogate key as in
StoreCategory
StoreCategoryID
StoreID
CategoryID
could I use that in the ProductCateogry table in place of the StoreID and CategoryID columns?
ProductCategory
ProductID
StoreCategoryID
I'm not sure I like that either.
Can someone help me see where I'm wrong with these relationships?
Thanks in advance.