List:General Discussion« Previous MessageNext Message »
From:Arthur Fuller Date:January 2 2010 4:20pm
Subject:Re: How Set Up This Table
View as plain text  
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 :)

hth,
Arthur

On Fri, Jan 1, 2010 at 5:09 AM, Victor Subervi <victorsubervi@stripped>wrote:

> Hi;
> 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
> which
> 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?
> TIA,
> Victor
>
> --
> The Logos has come to bear
> http://logos.13gems.com/
>

Thread
How Set Up This TableVictor Subervi1 Jan
  • Re: How Set Up This TableArthur Fuller2 Jan
    • Re: How Set Up This TableVictor Subervi2 Jan
      • Re: How Set Up This Tableprabhat kumar2 Jan
        • Re: How Set Up This TableVictor Subervi2 Jan
    • Re: How Set Up This TableVictor Subervi2 Jan
      • Re: How Set Up This TableArthur Fuller4 Jan
        • Re: How Set Up This TableVictor Subervi4 Jan