timestamp as primary key?

From: "Joe Kramer" <cckramer(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: timestamp as primary key?
Date: 2006-10-19 11:13:31
Message-ID: b4c00a110610190413q1559c2ffubc90d3c5d6679021@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I have table for online chat system that keep messages sent between users.

CREATE TABLE chat_message
(
message_time timestamp without time zone NOT NULL DEFAULT now(),
message_body text,
user_id_from bigint,
user_id_to bigint,
CONSTRAINT chat_message_pkey PRIMARY KEY (message_time)
)
WITHOUT OIDS;

I don't want to add int primary key because I don't ever need to find
messages by unique id.

Question: is it okay to use timestamp as primary key, or there is
possibility of collision? (Meaning two processes may INSERT into table
within same millisecond.) It is a web application.

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomasz Ostrowski 2006-10-19 11:27:15 Re: timestamp as primary key?
Previous Message Rodrigo Sakai 2006-10-19 10:51:17 Interval referential integrity