From: | Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com> |
---|---|
To: | PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Foreign key check only if not null? |
Date: | 2011-09-13 01:48:23 |
Message-ID: | CAFWfU=voXQ4p2fNqQ=6RtU0uT+SSgf6T+NDWbCrBKV4yW+9YXw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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!
From | Date | Subject | |
---|---|---|---|
Next Message | Reid Thompson | 2011-09-13 01:54:05 | Re: Need help with what I think is likely a simple query - for each distinct val, return only one record with the most recent date. |
Previous Message | Reid Thompson | 2011-09-13 00:54:16 | Need help with what I think is likely a simple query - for each distinct val, return only the record with the most recent date. |