primary key is a candidate key to uniquely identify each row in a table. A
unique key or primary key comprises a single column or set of columns. No
two distinct rows in a table can have the same value (or combination of
values) in those columns. Depending on its design, a table may have
arbitrarily many unique keys but at most one primary key.

a compound key is a key that consists of 2 or more attributes that uniquely
identify an entity occurrence.


On Sat, Jan 2, 2010 at 10:05 PM, Victor Subervi <victorsube...@gmail.com>wrote:

> 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
>



-- 
Best Regards,

Prabhat Kumar
MySQL DBA
Datavail-India Mumbai
Mobile     : 91-9987681929
www.datavail.com

My Blog: http://adminlinux.blogspot.com
My LinkedIn: http://www.linkedin.com/in/profileprabhat

Reply via email to