Hey all, I'm somewhat new to databases (did a bit 7 years ago, but...). And I'm busy trying to code a webstore (deep end etc), and am currently stuck on a barcode table....
Concept:
I have a seperate table with basic descriptions of products (mostly video games), however, I can have multiple items with different barcodes which are effectively the same product - say, a release from a seperate region that has identicle artwork and contents, just a different barcode.
Some though will differ slightly more, with a "Re-Release" version, which is still the same product description, but has different artwork and possibly slightly differing contents (not enough to change a basic description, but enough for me to just record that it's a re-release).
Also, for either a regular (non) re-release, or a re-release product, I may want to go "Search Amazon for prices this product". I then need a way to single out a single barcode that is most likely to give a return for a single product (the "original" regular release, or "original" re-release, or whatever's most likely to be found in the wild and used by most other stores).
Therefore, when one product has multiple barcodes for either a regular release or re-release, I need to lable one of them as a primary barcode.
Code:
Barcodes
id ProductID Barcode Re-release? Primary release?
1 1 711711 N Y
2 1 711712 N N
7 1 711715 N N
3 1 711713 Y Y
4 1 711714 Y N
5 2 819110 Y Y
6 2 819112 N Y
ID = unique id for table contents.
ProductID is a link to a description of the generic product.
Barcode is a unique barcode for a product.
Re-release is boolean, whether the release is a re-release product or not.
Primary, bool, should be set at least and only once for every unique productid/re-release pair on the most common barcode (ie. prod 1 re-release N, 1 / Y, 2 / N, 2 / Y, 3 / N, 3 / Y etc etc).
And I'm now having problems figuring out what to use as a key to avoid duplicate entries of Primay...
I want to limit "Primary" to only happen once for every ProductID / Re-Release pair (as above), however I still want multiple ProductID / Re-Release pairs which are not "Primary".
Using ProductID, ReRelease and PrimaryRelease doesn't work as I may have two or more entries for the same product, same re-release and not primary (something I realised when adding id 7 above). I could use them, but it would limit me to only two entries for each PrductID/Rerelease pairing.
Adding the barcode in to a key, although it probably be *a* key, doesn't look like it will prevent there being multiple "Primary" entries per pid/re pair.
Any ideas how I could go about it? Anyone saying "make a new table" gets no beer, this is already a new table having been split from the products db on other advice, and I'm just getting more confused as I go along
