Search Postgresql Archives

Foreign key check only if not null?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I bet this is a simple solution but I have been racking my brains.

I have a column in my table:

    user_id  varchar(100) ;

This can be NULL, or it can have a value. If it has a value during
INSERT or UPDATE, I want to check that the user exists against my
"Users" table. Otherwise, NULL is ok. (Because the functionality in
question is open to both unregistered and registered users).

Any idea on how I can implement a FOREIGN KEY constraint? Or do I need
a pre-insert and pre-update RULE for this?

Thanks!

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux