On Sat, Jan 2, 2010 at 11:20 AM, Arthur Fuller <fuller.art...@gmail.com>wrote:
> Hi Victor. > > I think that the first thing you need to consider is whether a product can > be in more than one package, and second is whether a package can be in > another package. Also, I don't know why you need to auto-generate in either > case. It's pretty simple DDL. > > Case 1: product can only be in one package: > > 1. Add a Packages table with columns PackageID and PackageName and probably > PackagePrice. > 2. Add a PackageID column to the Products table and make it a foreign key > referencing Packages. > > Case 2: product can be in multiple packages: > 1. Same as above. > 2. Create a ProductPackages table that contains PackageID and ProductID, > both as foreign keys into Products and Packages. > 3. Decide whether you want a compund PK on this new table, or you want > instead an auto-increment column that would be the PK. (There are > differences of opinion on this one, so I'm leaving it alone; I don't want to > start a religious war :) > Thanks! That's reversing my thinking! I hadn't considered working the other direction. What is a PK and a compound PK? TIA, V