mysql primary key id debate
ross at agilestudios.com
Fri Dec 30 10:07:32 MST 2005
On Thu, 29 Dec 2005, Gary Thornock wrote:
> I prefer client_id, both because the name matches when I use the
> key as a foreign key in another table,
I understand this justification, although I personally prefer "id", but
> and because there are frequently multiple $x_id fields in a table, and
> it's useful to distinguish between them.
I don't understand this justification. Are you saying that a table
frequently has more than one primary key? Or are you saying that you
prefer foreign keys to be of the format $x_id?
If the latter, unless I misunderstood, that was never under debate--I
think everyone prefers $x_id for foreign keys. The argument is between:
(Table "foo" with two foreign key columns)
> As for having a base getID function, why not have one that knows
> that the primary key field is always $tablename_id?
I agree; in actual code you can have it always prefix the table name when
calling getID() or the like. This isn't really an issue IMO.
More information about the PLUG