I have been learning about SIMPLE
and FULL
matching foreign keys in PostgreSQL and I am wondering if the following thought process is correct:
Once at least one of the referencing columns of the foreign key contains a NULL
value, there is no link to the referenced table. This is because a NULL
is not comparable with another NULL
value, as per 3VL. This also means that defined cascading actions (such as ... DO DELETE
, ... DO SET NULL
, ..) when a referenced row which contains at least one NULL
value in the relevant columns, is updated or deleted will never happen, because there is no link to the referenced row. More concrete, assume a foreign key from table A(x, y)
to B(x, y)
. If both A
and B
contain a row (5, NULL)
for x
and y
, there is no link, because the NULL
for the row in A
is not equal to the NULL
for the row in B
.
Is this correct? I am quite new to SQL, so I am wondering if I understood this correctly.