I would concur.  My understanding is there is one primary key -- however if
you use a junction table then in reality you need two columns to create a
unique identifier that results in a single primary key -- albeit composed of
two columns.  To some that might appear to be two primary keys -- and to
others it may be seen as one.  I believe, to the DB it is seen as one.  To
we humans looking at the table it would appear as two distinct keys as we
can operate separately on each column. . . anyway.

I am developing some wrappers to the DBI and DBD::mySQL module to provide a
standardize method to accessing DBs without extensive prior knowledge of the
DB structure.  And some standard SQL statements use the primary key as a
default. . .which lead me to previous question.

-----Original Message-----
From: Dan Horne [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 22, 2001 9:20 PM
To: Vuillemot, Ward W
Subject: RE: multiple primary keys


I can't speak for mySQL, but by definition there is only one primary key
allowed per table in Relational Database theory.

You can, however, enforce uniqueness against other columns by using a unique
key.

Not all primary keys have to be based on incrementing values. For instance a
city lookup table could have a primay key based on the city names. Not all
databases have autoincrementing values in tables either. Oracle doesn't, as
it uses sequences which are independent objects that are not associated with
a table.

I only responded because you mentioned "all DBs." Unfortunately, I know
nothing about mySQL

Dan

-----Original Message-----
From: Vuillemot, Ward W [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 23, 2001 11:51 AM
To: [EMAIL PROTECTED]
Subject: multiple primary keys


I have a question regarding multiple primary keys. Do all DBs handle multple
primary keys?  In addition, can only one of the primary keys be
autoincremented?
I am curious how this pertains to mySQL where we have:
        $sth->{'mysql_insertid'};

Is there a way to determine the name of column that was autoincremented?
Easily, that is. . . .ie, a simple command such
        $sth->{'hashValueHere'};

Thanks,
Ward

Reply via email to