Re: Table and Field namestyle best practices?

From: novnov <novnovice(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Table and Field namestyle best practices?
Date: 2006-11-12 22:21:10
Message-ID: 7308343.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


OK, thanks. I'm having a major internal debate about how I'm going to adjust
my habits to pgsql's 'lowercase is simplest' reality, all of this is
helpful.

One thing I've not been able to determine is if there are any characters
besides the standard alphanumeric ones and "_" that do not invoke the double
quoting of names. Are there any? If there were others, it'd be nice to know,
for possible use as namespace markers ("_" is most commonly used for this,
maybe it's the only real candidate).

Dawid Kuroczko wrote:
>
> On 11/8/06, novnov <novnovice(at)gmail(dot)com> wrote:
>> I am very curious to hear the various conventions folks here have arrived
>> at. I don't expect there to be consensus, but the various rationales
>> might
>> help me arrive at an approach that works well for me.
>
> Personally I use all lower caps names a typical table might look:
>
> CREATE TABLE names (
> name_id serial PRIMARY KEY,
> name varchar(100) UNIQUE NOT NULL,
> birth date
> );
> CREATE INDEX names_birth_index ON names (birth)
> CREATE INDEX names_name_lower_index ON names (lower(name));
> CREATE TABLE winners (
> winner_id serial PRIMARY KEY,
> name_id integer REFERENCES names
> );
> CREATE VIEW winner_names_view AS
> SELECT * FROM winners JOIN names USING (name_id);
>
> ...generally I don't like naming columns like 'id' -- if I put
> full names, like name_id then JOIN ... USING(col_id) or
> NATURAL JOINs are easy and straightforward.
>
> Sometimes I put a trailing "_view" to mark that given table
> is really a view. My index names are composed of
> table_col1_col2_index or table_col1_function_index
> (like the above lower() case). If index is unique,
> I use "_key" as a suffix instead of "_index".
>
> I know couple of people who name their tables like
> T_Name, T_Winner etc. (and V_For_Views), but I consider
> it a bit superfluous for my tastes. And if I have whole a lot
> tables, I like to keep them organized into schemas, which
> are powerful beings in PostgreSQL.
>
> Regards,
> Dawid
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>

--
View this message in context: http://www.nabble.com/Table-and-Field-namestyle-best-practices--tf2596761.html#a7308343
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Nolan 2006-11-13 01:35:54 Re: Why isn't it allowed to create an index in a schema other than public?
Previous Message Andrus 2006-11-12 21:39:09 Re: Why overlaps is not working