Does a Foreign Key referencing a Primary Key need the NOT NULL constraint in a PostgreSQL database?
The database is highly normalized and will be very large. I do not wish to add extra constraints that will slow down the queries even more if said queries are unneeded.
If you want to be able to represent unknown in the FK column of that table, then make it nullable, if it has to have a value, make it Not Null.
You can have as many records as you want in the referencing table with null FK values. The unique constraint is on the rows in the referenced table (Where the PK is) not on the rows in the referencing table (where the FK is).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With