Multi-Word Field Names

absolutely not

none that i know

my own preference is to use single words for column names whenever possible – the whole problem just goes away, doesn’t it – but when necessary, an underscore

Not really. How about these examples…

“LogInStatus” vs. “LoginStatus” vs “log_in_status”

“SiteMapLink” vs SitemapLink" vs “site_map_link”

“SitePointNumber” vs “SitepointNumber” vs “sitepoint_number”

“EMailAddress” vs “EmailAddress” vs “email_address”

“ECommerceLink” vs “EcommerceLink” vs “ecommerce_link”

and a very common one…

“ZIPCode” vs "ZipCode vs “Zipcode” vs “zip_code”
(Did you know that out of the first three Upper/Lower-case choices for zip_code, only one is truly correct? Do you know why?)

Adding an underscore between words is much less likely to be misinterpreted than using capitalization between words, as seen above.

TomTees

So how does that translate for “First Name”?

fname?

firstname?

first?

TomTees

Camel case for variables and never underscore… the reason? Underscores are harder to type in my Spanish keyboard… unlike English keyboards, typing an underscore is not just hitting a key but a key combination with the shift key. Not much of a problem but I don’t see why I need to delay 0.5 secs every time I need to write a multiple word name.

I try to use single names when possible, of course.

lower case underscores for me. reason? table names can be case sensitive, so I just extend that and always use lower case when dealing with the database. Underscores are just for readability.

Seeing as I use camelCase for variable names in PHP I also use camelCase for database field names.
I don’t like the PascalNames because to me something that starts with a capital is a class name, whereas something that starts with a lower case is a variable. So, as I use ActiveRecord for PHP and I need to create a PHP class for each table, and I already said I use PascalCase for classes, I use PascalCase for tablenames.
Somehow I don’t like underscores in my databases, but I do use underscores in CSS. Colour me undecided :slight_smile:
The puteverythingtogether approach is fine for short thing like “firstname”, but for longer names it just becomes unworkable.
As for the spaces … no comment :slight_smile:

login_status vs log_in_status

sitemap_link vs site_map_link

sitepoint_number vs site_point_number

email_address vs e_mail_address

ecommerce_link vs e_commerce_link

zip_code vs z_i_p_code

Admittedly this one is far fetched but if you accept that ZIP is an initialism, both are plausible.

Rubbish I’m afraid. Wherever there is ambiguity with capital letters, there is ambiguity with underscores. The only example that even had some merit was Zip Code, but I’m pretty sure Zip is one word in that case (despite being an initialism, that is not its common usage), not all capitalised. In any case, I’m not American so it isn’t something I have to deal with anyway!

Not if he toggles caps-lock :stuck_out_tongue:

Apart from the 3 bytes data traffic (saleUnitPrice is 3 bytes shorter than sale_unit_price) which is completely negligible, I don’t see why it should.

No

Not being an object-oriented developer by nature, I’ve never had that problem. Although since I hope to make this my first-ever OOP project, that is a good point.

I used to be big on PascalNames, but someone pointed out that it makes it tougher on other developers who may not know exactly how you change case.

By using underscores (_), you make it simplier in that it is just all words in lower-case with an _ between words.

It is slightly more verbose, but I’ve grown to like it for predictability reasons.

TomTees

And you don’t need a key combination to get a capital? :shifty:

Very good, Mittineague. You get the prize!!

In it’s original form, it should be “ZIP code”, but in modern American English it can be “ZIP code” or “Zip Code” or “Zipcode” or “Zip”.

TomTees

yeah, any of those

:slight_smile:

You were adding underscores for hyphenation and breaking up words like “Sitepoint” into two words when it is one, so I don’t think my examples were as ambiguous as your made them out.

Assuming you know “Sitepoint” is one word, then it can only be “sitepoint_number” using my approach.

By contrast, it could be “Sitepoint” or “SitePoint” since there are a lot of compound words that use mid-word capitalizations (e.g. “NetApp”) which leads to confusion above the using Pascal Case.

In the end, you can debate anything.

I was just explaining why others have told me that using underscores to break up complete words seems less ambiguous. :wink:

TomTees