| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> | 
|---|---|
| To: | Melvin Davidson <melvin6925(at)gmail(dot)com> | 
| Cc: | Kynn Jones <kynnjo(at)gmail(dot)com>, pgsql-general General <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: On using doubles as primary keys | 
| Date: | 2015-04-17 15:56:33 | 
| Message-ID: | CAKFQuwZmvar24Tan2-5E2mUc5MuU4T3zorfNbOKLaAMv=osWwA@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On Fri, Apr 17, 2015 at 8:45 AM, Melvin Davidson <melvin6925(at)gmail(dot)com>
wrote:
> 
> On Fri, Apr 17, 2015 at 11:34 AM, Kynn Jones <kynnjo(at)gmail(dot)com> wrote:
>
>>
>> One consideration that is complication the choice of primary key
>> is wanting to have the ability to store chunks of the data
>> table (not the metadata table), including the PK column, as
>> matrices of doubles.  In its simplest form, this would mean using
>> doubles as primary keys, but this seems to me a bit weird.
>>
>> I'm willing to go ahead with this, but I wanted to ask for your
>> feedback on the whole thing.  In particular I'd like to know if
>> there are there standard ways for using doubles as primary keys,
>> and, conversely, if there are known pitfalls I should be looking
>> out for, but I welcome any other words of wisdom you may have on
>> this topic.
>>
>
MD>> 
First, please ALWAYS include the version and O/S, even with basic questions.
MD>>
I'm not sure what you mean by doubles. Do you mean bigint data type, or do
you mean use two columns for a primary key? Either way it's pretty simple.
MD>>
If you mean a bigint, then probably best to use serial data type, which
will default to the next value.
MD>>
If you mean use two columns for a Primary Key, the you just specify the
columns.
MD>>
EG: CONSTRAINT PRIMARY KEY table_name_pk PRIMARY KEY (col1, col2)
I take it the OP means "double precision" 
http://www.postgresql.org/docs/9.0/static/datatype-numeric.html
I'd be suspect of choosing a PK whose type definition includes the word
"inexact".
You also say you want to store the data as a double precision but you never
actually explain what the natural key of the data is.
If you are strictly storing serial (big) integers but doing so within a
double precision typed column you may be OK - but I would advise taking
input from someone with more expertise on the properties of IEEE floating
point numbers.
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Qingqing Zhou | 2015-04-17 18:10:16 | Re: Waiting on ExclusiveLock on extension | 
| Previous Message | Jeff Janes | 2015-04-17 15:55:26 | Re: Waiting on ExclusiveLock on extension |