mysql primary key id debate

Jeff Schroeder jeff at
Thu Dec 29 16:19:36 MST 2005

Kirk wrote:

> The argument is to name it "id" or another name like "client_id".
> I like client_id because then the primary key name matches the
> foreign key in another table.
> My coworker likes just the name id because then he can have a base
> class called getId()

Personally, I always have a column in each table called "id", and then 
if I'm using it as a foreign key in another table, I reference it as, 
e.g., "client_id".

By that I mean I might have a client table:

id integer primary key auto_increment
blah blah other data fields

and then a table that contains, say, documents for that client:

id integer primary key auto_increment
client_id integer default 0
blah blah other data

Here, there might be multiple client documents, and each of them will 
contain a client_id value matching the id field of a client record.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : 

More information about the PLUG mailing list