mysql primary key id debate

Gary Thornock gthornock at yahoo.com
Thu Dec 29 22:22:36 MST 2005


--- kirk <kirk at emstraffic.com> wrote:
> Myself and three other programers have been arguing (for well
> over an hour) about naming the primary key in a mysql database
> table.  I was wondering what other people name it.
>
> 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() that returns the value of the id column of that
> table.

I prefer client_id, both because the name matches when I use the
key as a foreign key in another table, and because there are
frequently multiple $x_id fields in a table, and it's useful to
distinguish between them.

As for having a base getID function, why not have one that knows
that the primary key field is always $tablename_id?




More information about the PLUG mailing list