CodeIgniter Forums

Full Version: Table names, singular or plural
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]SpooF[/eluser]
Just curious as to what others usually use/prefer.

El Forum

[eluser]ipsod[/eluser]
I prefer singular for simplicity's sake, but use plural because that's the standard with DMZ.

El Forum

[eluser]snifty[/eluser]
This is an interesting question, old though it may be.

Various plugins and libraries seem to have different ideas about this. For instance, Phil's base model expects singular table names:

https://github.com/philsturgeon/codeigniter-base-model

...although it supports alternatives. As ipsod describes, Datamapper wants plural table names:

http://stensi.com/datamapper/pages/models.html

I guess there's no way to standardize so that such packages can work together without hacking Sad

El Forum

[eluser]TWP Marketing[/eluser]
I use both, depending on the content or intended usage of the table, ie;
'control' would have a single (or at most a few) records.
'users' would have multiple records.
'admin' usually a single intended usage (could have multiple records but intent is administration).
'customers' multiple unique records.

Also, the singular/plural usage is language and culture dependent.

I'm just glad there is no "required" format for table names.
But the Federal Bureau of Coders (FBC) may have other ideas... (joke, but watch your six.)

El Forum

[eluser]snifty[/eluser]
Yeah, I guess I agree with you. It can be a pain to rename everything, which is what I'm facing. Time to start a branch in Git & see what breaks after I start renaming! I should really learn to unit test too Tongue

But I suppose it's better not to have the whole framework demanding one convention over the other.

What's "my six"? Smile

El Forum

[eluser]ipsod[/eluser]
6 as in 6 o'clock on an analog clock - behind you.

El Forum

[eluser]John_Betong_002[/eluser]
Off topic:

Quote:Yes, it means there is danger behind you. It comes from the military, I think.

If you imagine you are at the center of a clock, "12 o'clock" means right in front of you, and "6 o'clock" means right behind you. This allows you to tell someone else very quickly where someone else is in relation to you if you are in a jet plane, I guess. "Enemy spotted at 3 o'clock!", etc.

But, "watch your six" is usually used by the mainstream as an interesting way of saying "watch your back", as in a warning that people are out to betray you or that you are in danger that you maybe can't see.
It was news to me and I Googled for the above.
 
 

El Forum

[eluser]TWP Marketing[/eluser]
@John_Betong: Thanks for the clarification of my joke. I should have known 'six' would not be common usage outside the US. Yes, I meant that we, as programmers/coders, should beware of those who would try to enforce arbitrary standards on our work. I fear that we will see an 'FBC' created sometime in the future, if it doesn't exist already. The names of some large companies come to mind... (not joking).
And thanks for the link to the php_variables_test table! I've bookmarked it.

Also, since I haven't used DMZ, I did not realise that it enforces the use of singular and plural names between tables and models. Personally, I would not have forced the names to be different, it seems a lot of effort to make the human language syntax work. No offence intended, DMZ is an excellent tool!

If there is another reason for that particular naming convention, I'd appreciate hearing it.

El Forum

[eluser]snifty[/eluser]
I'll have to add "watch your six" to my vocabulary. ;-)

Anyway, I'm still struggling to get all this plural/singular stuff worked out in my app. Hopefully I cna get it back in working order and the base model I want to use running.

El Forum

[eluser]cahva[/eluser]
And with datamapper, you actually can use both(or whatever) if you want. Its just a matter of defining the table name in the model(eg. var $table = 'user'; ).

Watch your six was known to me(Im from Finland) but I watch too much hollywood movies anyways Big Grin