dbTalk Databases Forums  

Column naming standard – general opinions

comp.databases.postgresql comp.databases.postgresql


Discuss Column naming standard – general opinions in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gargoyle60
 
Posts: n/a

Default Column naming standard – general opinions - 11-20-2009 , 04:33 AM






Don't want to start a long-winded discussion, just seeking some
general views. . .

I was trained in SQL years ago and was encouraged to use lower-case
letters with words separated for emphasis using the underscore
character, for example:
customer_num, employee_id, invoice_line, transaction_code

I've stuck with this approach ever since, but now that I make use of
oo programming the general standard is to name oo instance variables
without underscores and capitalising all words except the first for
emphasis, such as:
customerNum, employeeId, invoiceLine, transactionCode

(I appreciate that this will mean quoting the identifiers in SQL
statements)

However, bridging the gap between relational databases and oo
programming means that when binding table column names to object
variable names, I really need to pick one or the other (you may
disagree but that's my aim).

So, when it comes to naming columns, what are most of you using?

Reply With Quote
  #2  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Column naming standard – general opinions - 11-20-2009 , 05:15 AM






gargoyle60, 20.11.2009 11:33:
Quote:
However, bridging the gap between relational databases and oo
programming means that when binding table column names to object
variable names, I really need to pick one or the other (you may
disagree but that's my aim).
Why?

I don't see a reason (nor a restriction) why you need to use the column names from the database as the variable names in your program.

Thomas

Reply With Quote
  #3  
Old   
gargoyle60
 
Posts: n/a

Default Re: Column naming standard – general opinions - 11-20-2009 , 06:14 AM



On Fri, 20 Nov 2009 12:15:25 +0100, Thomas Kellerer
<OTPXDAJCSJVU (AT) spammotel (DOT) com> wrote:

Quote:
gargoyle60, 20.11.2009 11:33:
However, bridging the gap between relational databases and oo
programming means that when binding table column names to object
variable names, I really need to pick one or the other (you may
disagree but that's my aim).

Why?

I don't see a reason (nor a restriction) why you need to use the column names from the database as the variable names in your program.

Thomas
You're right, of course. I've partially implemented a Facade pattern
which takes care of the translation via a ColumnMap so that the
database column names are different from the program variable names.

Reply With Quote
  #4  
Old   
gargoyle60
 
Posts: n/a

Default Re: Column naming standard – general opinions - 11-22-2009 , 03:12 PM



Thanks to all who reponded.

Reply With Quote
  #5  
Old   
Marco Mariani
 
Posts: n/a

Default Re: Column naming standard – general opinions - 11-23-2009 , 03:04 AM



gargoyle60 wrote:


Quote:
I've stuck with this approach ever since, but now that I make use of
oo programming the general standard is to name oo instance variables
without underscores and capitalising all words
Not really. In some languages, but they are despised in Python for
instance (see PEP8)


Quote:
except the first for emphasis, such as:
customerNum, employeeId, invoiceLine, transactionCode
Don't do that, please :-)

If upper case identifiers are ugly in SQL, the mixed-case ones are
directly spawned by Cthulhu, and treated differently by each vendor.


Quote:
However, bridging the gap between relational databases and oo
programming means that when binding table column names to object
variable names, I really need to pick one or the other (you may
disagree but that's my aim).
Unfortunately, we don't bridge any gap by directly mapping columns to
attributes/methods - or there wouldn't be any gap at all.

Quote:
So, when it comes to naming columns, what are most of you using?
I would use lower_case for object attributes as well, if there is no
sound reason to do otherwise.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.