Subject Re: [firebird-support] Nullable foreign keys
Author Paul Vinkenoog
Hi Christian,

> for me it is not only sub-optimal, but also unsatisfying, because
> all of my FKs are linked to the PKs of other tables which must never
> be NULL.

> Any other idea how I can do this?

You define the PKs as a non-nullable datatype - like you already do.

You define the FKs as the same datatype, but nullable. For instance:

create domain DID integer not null;
create domain DID_NULL integer;

create table Mutter (
id DID primary key
);

create table Kind (
id DID primary key,
mutti DID_NULL references Mutter( id )
);

Now each record in Kind can have the mutti field NULL, but if it's
non-NULL it *must* refer to an existing id in Mutter.


Greetings,
Paul Vinkenoog