views:

132

answers:

1

Hi,

is anywhere a detailed manual about PostgreSQL naming conventions? (table names vs. camel case, sequences-primary key-constraits etc.)

thanx!

+8  A: 

Regarding tables names, camel case, etc, the prevalent convention is:

SQL keywords in upper case, names (identifiers) in lower case, with underscores as separators, e.g.:

UPDATE my_table SET xxx = 5;

I don't like to use camel case in identifiers, they are folded to lowercase internally when not quoted. But anyway it's acceptable (as well as using upper case), as long as you are consistent: either quote them always or never (and this includes the schema creation).

I am not aware of many more conventions or style guides. Surrogate keys are normally made from a sequence (usually with the serial macro), it would be convenient to stick to that naming for those sequences if you create them by hand (*tablename_colname_seq*).

See also some discussion here, here and (for general SQL) here, all with several related links.

leonbloy