He may mean a composite primary key, which is a primary key based on two columns. On
whether this is a good idea or not it's really a question of whether you want to use 
natural or surrogate keys on your tables. 

A composite key is typically a natural key. A natural key is a key with information
attached to the columns in the key. Examples of a natural key would be a user's email
address. The problem with natural keys is that the data in the key frequently needs
to be changed. In the example of an email address as the key you would have to update
the key whenever anyone changed their email. Also on performance , joins tend to be
slower because the natural keys take more space then say a number to uniquely identify
the row.

I prefer surrogate keys which are keys that don't have any information tied to them. 
They are simply a sequence or autoincrement. Their only purpose is to to uniquely 
identify 
the row. They're better on join performance and you don't find people updating them 
because 
of changes in the data. 

If I were he, I would create an additional autoincrement field for the primary key and 
create a
unique index on the two fields he planned on being the primary key.

Dave Turner


On Wed, Aug 29, 2001 at 12:22:22PM -0500, Paul DuBois wrote:
> At 10:33 AM -0500 8/29/01, shawn reed wrote:
> >is it generally recommended / a good idea to have more than one PRI index
> >in the same table?  i've never seen that before until today while trying
> >to track down bugs in someone else's system and noticed a table with 2 PRI
> >indexes.  will this cause any problems?
> 
> ?
> 
> In MySQL, you cannot have two PRIMARY KEY indexes.  You can have a PRIMARY
> KEY and and a UNIQUE index, or two UNIQUE indexes, but that's a slightly
> different situation.
> 
> >
> >tia.
> >
> >~shawn
> >
> >
> >---------------------------------------------------------------------
> >Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> >To request this thread, e-mail <[EMAIL PROTECTED]>
> >To unsubscribe, e-mail <[EMAIL PROTECTED]>
> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 
> -- 
> Paul DuBois, [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to