Which naming convetions you are using? (1 Viewer)

jaryszek

Registered User.
Local time
Today, 16:14
Joined
Aug 25, 2016
Messages
756
Hi,

What naming conventions for tables and fields you are using?

Do you use FirstName as field name or first_name?

What if you are linking your access database with BE like MS SQL server, postgresql or oracle?

Best,
Jacek
 

isladogs

MVP / VIP
Local time
Today, 23:14
Joined
Jan 14, 2017
Messages
18,186
I always use CamelCase with no underscores and of course no spaces or special characters

Same in both Access and SQL Server


Sent from my iPhone using Tapatalk
 

jaryszek

Registered User.
Local time
Today, 16:14
Joined
Aug 25, 2016
Messages
756
hi ridders,

what if you read these tables from ms sql server?

When I moved all tables from Access to postgres all letters from Camel Case was changed to small letters (t_ServerMemory --> t_servermemory).

And this servermemory now it is not easy to read.

Best,
Jacek
 

isladogs

MVP / VIP
Local time
Today, 23:14
Joined
Jan 14, 2017
Messages
18,186
No issue reading CamelCase for field or table names in Sql Server linked tables.
I don't use postgres .... or MySQL.
 

jaryszek

Registered User.
Local time
Today, 16:14
Joined
Aug 25, 2016
Messages
756
Thank you Ridders,

what about others? Prefer CamelCase or snake letters?

Best,
Jacek
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 10:14
Joined
Jan 20, 2009
Messages
12,849
My first rule after no reserved words and special characters is no underscore in names.

The underscore is too strong a separator because we rely mostly on the top of characters to recognise them quickly. A name should hang together and variants of CamelCase do a better job.

The underscore is also used in modules to separate the object from the event. And the default names on imported tables from MS SQL Server. And the aliases in the query designer when including the same table twice.

Best just stayed away from in your own names.
 

Minty

AWF VIP
Local time
Today, 23:14
Joined
Jul 26, 2013
Messages
10,355
CamelCase is by far the easiest to quickly scan and read.

I tend to use some prefixes in development zzz or aaa to indicate a new dev or old object version rather than trying to use numbers.
 

jaryszek

Registered User.
Local time
Today, 16:14
Joined
Aug 25, 2016
Messages
756
Ok.
Thank you Guys,

but when you are writimng queries in database directly, there is a problem with CamelCase, in postgres you have to use quotes "" to say to application that you want to use exact field name.

In MS SQL Server also?

Best,
Jacek
 

Minty

AWF VIP
Local time
Today, 23:14
Joined
Jul 26, 2013
Messages
10,355
No - a typical MS SQL query is very similar to an access one ;

Code:
SELECT Field1, Field2, Field3, 'Fred' As Field5
FROM Table1
WHERE DateField4 = '2018-07-20'

Field names and Table names aren't case sensitive in MS SQL Server, are you saying they are in PostGres ?
 

jaryszek

Registered User.
Local time
Today, 16:14
Joined
Aug 25, 2016
Messages
756
Yes Minty,

you can not write

Code:
Select FieldName from Table1
, you have to write
Code:
Select "FieldName" from Table1

so CamelCase is not always good i think...

Best,
Jacek
 

isladogs

MVP / VIP
Local time
Today, 23:14
Joined
Jan 14, 2017
Messages
18,186
Why wouldn't CamelCase be OK even if its necessary to add ""?

BTW I didn't realise that using an underscore is referred to as snake_letters
Learn something new every day!
 

jleach

Registered User.
Local time
Today, 19:14
Joined
Jan 4, 2012
Messages
308
Just an FYI, once the table is linked in Access, you can rename the Access linked table to whatever you want. I usually use a SQL backend, in which case Access by default replaces the schema separator with an underscore, so dbo.Employees becomes dbo_Employees. First thing I do after linking a new table is rename the linked table to Employees. (Access maintains the name of the target table in your PostgreSQL/MySQL/MSSQL db within other properties: this does not affect what table is linked to when you change the name).

I'm not sure what using quotes with CamelCase has to do with naming conventions... doesn't make sense that if you use CamelCase, you have to also include the quotes (as opposed to any other convention...). In SQL Server (and Access), an object with a name as a reserved word can be explicitly noted by using square brackets: [dbo].
.[Description]... is that what you're asking about?

I know MySQL tends to prefer backticks: `MyField` (which I always found rather ridiculous, along with the look_im_a_php_and_mysql_developer convention).

Anyway, CamelCase (or PascalCase if you prefer, some people consider camelCaseToStartWithALowercase) tends to be the norm for most Windows-based development.

Cheers
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 10:14
Joined
Jan 20, 2009
Messages
12,849
but when you are writimng queries in database directly, there is a problem with CamelCase, in postgres you have to use quotes "" to say to application that you want to use exact field name.

In MS SQL Server also?

Double quotes around object names is an ISO standard supported by SQL Server.

When writing a View or Stored Procedure using the facilities in the Management Studio there is a line included in the template:
Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]SET [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]QUOTED_IDENTIFIER [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]ON[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

This enables the use of double quotes as object delimiters and single quotes around strings. With it this setting OFF the T-SQL naming standard must be used. This the same as Access where names with spaces or special characters must be delimited with square brackets and either double or single quotes can be used for string delimiters.

Query and Table definitions for ODBC Data Connections in Excel use the quoted identifiers.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 19:14
Joined
Feb 19, 2002
Messages
42,977
I use CamelCase because except for the definition of a variable, I never have to use the shift key. Access proper cases the name when I complete the statement. If it doesn't, I know I've made a typo. Aside from requiring a shift, I also think the underscore is to strong a separator. I do occasionally use it when I want a strong separation but that is rare.
 

Cronk

Registered User.
Local time
Tomorrow, 10:14
Joined
Jul 4, 2013
Messages
2,770
I use CamelCase because except for the definition of a variable


Me too. Underscores only when preceding bit is in caps ie field name /variable eg VAT_Refund
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 19:14
Joined
Feb 19, 2002
Messages
42,977
I use CamelCase because except for the definition of a variable
I'm not sure I phrased that correctly.

Except for when a new variable is defined - might be closer. Obviously, if you want a variable to include Caps, you have to type them ONCE.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 18:14
Joined
Feb 28, 2001
Messages
27,001
Actually, there are times when you have to remember to type the case correctly anyway because sometimes auto-correct corrects the wrong way.

IF you have a mixed-case ENUM statement (to give names to possible integer values that represent symbolic states via numbers), and if you type the declaration in mixed case, but THEN at some point type the enumerated name in all lowercase, ALL INSTANCES of the ENUM name go back to lower case. If you then go back to the original definition and type it correctly, that fixes it. But it is truly BIZARRE the first time you see that happen.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 19:14
Joined
May 21, 2018
Messages
8,463
camelCase in database objects
PascalCase in code

Code:
dim FirstName as string
FirstName = RS!firstName
 

jleach

Registered User.
Local time
Today, 19:14
Joined
Jan 4, 2012
Messages
308
Actually, there are times when you have to remember to type the case correctly anyway because sometimes auto-correct corrects the wrong way.

IF you have a mixed-case ENUM statement (to give names to possible integer values that represent symbolic states via numbers), and if you type the declaration in mixed case, but THEN at some point type the enumerated name in all lowercase, ALL INSTANCES of the ENUM name go back to lower case. If you then go back to the original definition and type it correctly, that fixes it. But it is truly BIZARRE the first time you see that happen.

Yea, this has been a pet peeve for years.

As a quick workaround, you can use the fully qualified enum name instead of just member:

Code:
Public Enum SomeStuff
  StuffThis = 0
  StuffThat = 1
End Enum

Then write:

Code:
If SomeVar = somestuff.

... when you hit the dot you get the intellisense and can pick it out of the list. You don't have to worry about the caps in the enum name (it's only an IDE bug for the members), and it's still faster/easier (IMO) than trying to write the perfect casing every time (especially when the member names are long)

I think the only place it doesn't work is within a case statement, but I still do this then a few quick keystokes to hop back and delete the left qualifier, still works pretty well.

OTOH, I'm a huge advocate of fully qualified naming, and even use it with modules and procedures. Much less to remember (https://dymeng.com/module-naming/)
 

Users who are viewing this thread

Top Bottom