[Dbix-class] DBIx::Class:Schema::Loader has_many relationshipnames

Peter Edwards peterdragon at users.sourceforge.net
Fri Feb 24 18:18:08 CET 2006


> Do most people really name their tables in the singular? I find that
> quite confusing.

It's very common practice for DBAs.
The reasoning is that a single record represents a single item.

Take for example a table holding car details.
One record is one car, so you'd call the table "car".
It doesn't matter so much on a simple system but once you have many tables
you will sooner or later end up with tables where one record represents a
set of something and then a plural name is a helpful mnemonic, particularly
when you start programming against it. 

my $car = DB::Car->find( name => 'Ford Focus' );
(one car record)

my $car = DB::Cars->find( name => 'Ford Focus' );
(is that one car or many? is $car a record or a recordset? should the
variable be $cars?)

It seems silly, but I've wasted a lot of time supporting systems with a mix
of pluralisation in table and variable names. When it's someone else's code
you need to keep referring to the db defs to work out what's happening.

Regards, Peter

 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.0.0/268 - Release Date: 23/02/2006
 




More information about the Dbix-class mailing list