Hi 3 G's
Thanks for persevering with this :-)
I hear what you say: "The same product comes in many different
categories."
(Note: in these conversations, "many" just means "more than one". It
does not necessarly mean "hundreds and hundreds".)
So, ProdID is /not/ unique within the products table: many records can
have the same ProdID. Similarly, CategoryCode is not unique within that
table: many records can have the same CategoryCode. Only the
/combination/ of ProdID /and/ CategoryCode, is unique within that
table.
In that case, you need a so-called "composite" primary key. A composite
PK is a PK which comprises more than one field. In your existing
products table, the primary key would be ProdID /plus/ CategoryCode. No
two records can have the same /combination/ of ProdID and CategoryCode.
You could show the composite key, like this:
ProdID ( composite )
CategryCode ( primary key )
(other fields)
However - this is how you would normally structure this. Note that I've
chosen my own table names below. Do not confuse my names, with yours.
tblProduct
ProdID (PK)
(other fields)
tblCategry
CategryCode (PK)
(other fields)
tblProductCategory
ProdID ( composite )
CategryCode ( primary key )
(other fields)
Huh? Why three tables?
Because then you can store the necessary information >>> without any
duplication <<<.
o tblProduct stores data that applies to the product as a whole, >>>
regardless of what categories that product might come in. <<< The data
in this table depends on the product, but not on the category. You do
not need to duplicate these [product details, in every category record
for that product.
o tblCategory stores data that applies to that category as a whole,
>>> regardless of what products (if any) might come in that category. <<< The data in this table depends on the category, but not on the product. You do not need to duplicate these category details, in every product record for that category.
o tblProductCategory stores data about a single product in a single
category. The data in this table depends on the /combination/ of
product /and/ category, so it can not go in either of the other two
tables.
I do not want to over-complicate the issue - but that is how you should
really structure your data, from what I can see so far.
Does that help? Or just confuse?
HTH,
TC (MVP Access)
http://tc2.atspace.com