PostgreSQL: NULL value in foreign key column

Solution 1:

Works for me in 9.3 after correcting a missing comma. I'm sure it will work also in 9.1

create table quotations (
    receipt_id bigint not null primary key
);

create table order_confirmations (
    receipt_id bigint not null primary key,
    fk_quotation_receipt_id bigint references quotations (receipt_id)
);

insert into order_confirmations (receipt_id, fk_quotation_receipt_id) values 
    (1, null);

Confirmation will include:

INSERT 0 1