Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread D'Arcy J.M. Cain
On Wed, 24 Oct 2007 09:43:10 +0200 Nis Jørgensen <[EMAIL PROTECTED]> wrote: > Well, I have a couple of times had the "need" to have a primary > key/uniqueness constraint with one column nullable (indicating "Not > Applicable"). The "problem" is that we have only one NULL, which for > comparison pur

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Robins Tharakan
Forgive my butting in, but frankly, most of the times, whenever I find myself in a very 'exceptional problem' such as this one, I always end up questioning the basic design due to which I am stuck in the first place. Paul, it seems that probably there is a basic design issue here. All the best :)

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Paul Lambert
Paul Lambert wrote: It's marked not null as a result of being part of the primary key for that table which I can't really get around. I can get away with not having the foreign key though, so I'll have to go down that path. Cheers, P. Ignore this whole thread actually. I need to rethin

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Nis Jørgensen
D'Arcy J.M. Cain skrev: > On Wed, 24 Oct 2007 11:00:47 +0800 > Paul Lambert <[EMAIL PROTECTED]> wrote: >> It's marked not null as a result of being part of the primary key for >> that table which I can't really get around. >> >> I can get away with not having the foreign key though, so I'll have t

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread D'Arcy J.M. Cain
On Wed, 24 Oct 2007 11:00:47 +0800 Paul Lambert <[EMAIL PROTECTED]> wrote: > It's marked not null as a result of being part of the primary key for > that table which I can't really get around. > > I can get away with not having the foreign key though, so I'll have to > go down that path. It can

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread Paul Lambert
Tom Lane wrote: If I'm understanding you correctly, the problem is not the foreign key, it's that you marked the column NOT NULL. A foreign key constraint by itself will allow a NULL in the referencing column to pass. You choose whether you want to allow that or not by separately applying a NO

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread Tom Lane
Paul Lambert <[EMAIL PROTECTED]> writes: > I have a table where one column references by foreign key a column from > another table. However, the column in this first table does not always > contain data which results in a not-null constraint violation when I > attempt an insert. > My question t

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread Phillip Smith
> My question therefore is, is it possible to create a foreign key that is > conditional, i.e. only enforce the foreign key where the value in that > table is not null. My understanding from reading previous threads on this topic is the answer is no, however you could make your own pseudo-foreign

[SQL] Quick question re foreign keys.

2007-10-23 Thread Paul Lambert
I have a table where one column references by foreign key a column from another table. However, the column in this first table does not always contain data which results in a not-null constraint violation when I attempt an insert. My question therefore is, is it possible to create a foreign ke