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
2. Add a PackageID column to the Products table and make it a foreign key
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 :)
On Fri, Jan 1, 2010 at 5:09 AM, Victor Subervi <victorsubervi@stripped>wrote:
> I have a table with products for a store to sell. I need to autogenerate
> from code a table or series of tables into which I can enter (and from
> I can retrieve) the ID numbers of products which I am going to associate
> together and their package price. Product associations will vary, in that
> one association may have 2 products and another 20. What is the best way to
> MySQL this?
> The Logos has come to bear