Re: Date and Timestamps

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Ying Lu <ying_lu(at)cs(dot)concordia(dot)ca>, pgsql-general(at)postgresql(dot)org
Subject: Re: Date and Timestamps
Date: 2004-08-18 19:18:18
Message-ID: 4123AB7A.20003@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephan Szabo wrote:

> [As a note, it's a bad idea to put a new message with a new problem in the
> same thread.]
>
> On Wed, 18 Aug 2004, Ying Lu wrote:
>
>>I have a question about "date" & "timestamp" types in PostgreSQL. I want
>>to setup the default value '0000-00-00' and "0000-00-00 00:00:00" for
>>them. However, it seems that PostgreSQL does not support it. Could
>
> Right, because those aren't valid values for those types. I think you
> have to choose between using a date (or timestamp) column and constraining
> the values to valid ones (for example, possibly '0001-01-01') or using a
> type that doesn't constrain the value to valid dates.

If it is truly unknown data, then how about two relations:

-- Known set of [col1 - col2]'s

T1 (col1 varchar(7) not null,
col2 varchar(4) not null,
col4 varchar(3) not null,
primary key (col1, col2));

-- Known set of dates of [col1 - col2]'s

T2 (col1 varchar(7) not null,
col2 varchar(4) not null,
col3 date not null,
primary key (col1, col2),
foreign key (col1, col2)
references T1 (col1, col2) on delete cascade
);

No NULLs and fully normalized. Create a view with outer joins as
appropriate.

Mike Mascari

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Arthur van Dorp 2004-08-18 19:30:36 Re: Web application: Programming language/Framework: Summary
Previous Message Dino Vliet 2004-08-18 19:18:00 Re: Web application: Programming language/Framework: Summary