On Thu, Dec 29, 2005 at 04:10:26PM -0700, kirk 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.
> Thanks.
It seems to be a shibboleth [1]. Pick one and be consistent.
I prefer to name it foo_id personally, for readability, because
it helps in queries.
As for the base class thing, if you're consistent in prepending
"table_name" to _id, then it should be just as easy to have a base class
method that gets the id for a certain tuple ("row").
-Roberto
[1] http://www.dict.org/bin/Dict?Form=Dict2&Database=*&Query=shibboleth
--
Dente lupus, cornu taurus petit.
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/