Re: limit table to one row

From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 15:45:52
Message-ID: Pine.LNX.4.58L.0906091042420.11099@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

g == gryzman(at)gmail(dot)com writes:

g> If you want to store period of time, why store it as varchar ?

g> just store two rows
g> create table foo(
g> n varchar,
g> val date
g> );

g> and store two rows:
g> "start", now(),
g> "end", now()+'something '::interval

g> Wouldn't that do, or is there something I misunderstand ?

Sure, that would work, but I'm having to retrofit this table to an
existing system. Much of the system I'm redesigning, but this piece
isn't too terribly important right now.

g> The approach with vertical structure, is used when people want to
g> store some particular state, say - kind of like structure in C, but in
g> SQL, and they create table for it with all the columns, etc, and have
g> to limit it to one row.

g> On the other hand, you could also use unique index on (1) approach
g> (say if you need more variety of types).

Got it.

--
Brandon

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vick Khera 2009-06-09 15:56:39 Re: postgres getting slow under heavy load though autivacuum is enabled
Previous Message Dimitri Fontaine 2009-06-09 15:45:29 Re: postgres getting slow under heavy load though autivacuum is enabled