I have a table with a foreign key to another table's id field.
For example Book.author_id foreign key of (to?) Author.id
However sometimes I want to have the author_id be null if I want to say the author is unknown. However this fails the table constraint for foreign keys.
Is there a way around this?
To get a foreign key constraint that allows NULL values, do nothing; it's the default.
If you wanted to force it to always have a valid reference, you would have to add a NOT NULL constraint.