LPW: Slides... DBIC and new recommendations!

Peter Corlett abuse at cabal.org.uk
Sun Nov 30 13:31:57 GMT 2008


On 30 Nov 2008, at 10:39, Leo Lapworth wrote:
[...]
> After a discussion with Matt Trout in the pub I am not as convinced  
> about my
> tip of putting an 's' at the end of a table name (there's now a  
> comment in
> the slides to this effect), but I need to do some testing before I  
> work out
> what I would actually recommend, at the moment I'd suggest  
> consistency is
> the best approach and adding the 's' does still make the relationships
> clearer when your learning, even if as Matt points out it makes the  
> Result::
> package name a bit odd (Result::Authors, being for a single author).

The only good reason I've found to prefer plural table names is that  
it means that you can have a table "users" and "groups" without  
colliding with SQL keywords. But since foreign keys referencing these  
tables will get called "user" and "group", you lose anyway.

DBIC works OK with tables and columns that are SQL keywords, but  
you'll still curse every time you drop to a SQL prompt for an ad-hoc  
query.

I've mostly fallen for singular table names for the same reason Matt  
gives. To solve the SQL keyword clash, I use synonyms: "account"  
instead of "user" and "party" instead of "group". Pick more  
appropriate synonyms if those don't suit your particular app, of  
course. (I also suspect a thesaurus ought to sit next to all the ORA  
books on everybody's desk.)




More information about the london.pm mailing list