'UNIQUE'

Ben Clewett <b.clewett@roadrunner.uk.com>

From: Ben Clewett <B.Clewett@roadrunner.uk.com>
To:
Cc: pgsql-novice@postgresql.org
Date: 2003-03-17T14:33:41Z
Lists: pgsql-novice
Hi,

To describe an optional 1:1 reference I am using the 'UNIQUE' keyword:

	key_foo INT UNIQUE,
	FOREIGN KEY (key_foo) REFERENCES ....

Does 'UNIQUE' allow multiple 'NULL' entries?

Ie:

key_foo
-------
   1
   2
   NULL
   9
   8
   NULL
   4
   NULL

If as I expect, this is not the case, could anybody recommend another 
way of forming an optional 1:1 reference?


--------x-------X-------x--------


I have a problem of 'stale' data.  I want to produce combo-box's of 
selectable options, which are PK's of a table.  In order to enhance the 
system, I want to be lazy and store the values in the control.  To do 
this I need some way of telling when the source table / view is out of 
date and the data has changed.

I could set up Triggers to amend some lookup table containing a 
timestamp of the change for a table.  But I am wondering if PostgreSQL 
stores the last write timestamp to a table somewhere where it can be 
checked easily?


Thanks again,

Ben Clewett.