[Dbix-class] Re: doing a search

A. Pagaltzis pagaltzis at gmx.de
Mon Jan 22 19:36:16 GMT 2007


* Matt S Trout <dbix-class at trout.me.uk> [2007-01-22 15:10]:
> Using only the table name is kinda foolish because it screws
> you when you have multi-col PKs.

Granted; I haven’t had such a case though. :-)  I think it’s
good practice to use surrogate keys in any case were you’re not
absolutely and completely certain that the key can positively
never ever ever change. Since I also haven’t had to use legacy
schemata, my only multi-col PKs have been (FK,FK) pairs in join
tables. And my surrogate key column is always called `id`, which
I wouldn’t bother mentioning in any case.

If I did have a multi-col PKs I’d want to refer to, I guess I’d
opt for also including the FK column name. But I wouldn’t drop
the extra label describing the relationship, so I’d end up with
`foo.author_user_asdf` referencing `user.asdf`. (Maybe I’d use a
double underscore to delimit the relationship from the referee or
something; not sure.)

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Dbix-class mailing list