Can a foreign key be NULL and/or duplicate?

A foreign key is a column or a set of columns in a table that establishes a link between the data in two tables. The value in the foreign key column(s) must match the primary key column(s) value in the related table.

A foreign key column can be defined as either nullable or non-nullable. If a foreign key is defined as non-nullable, it cannot contain a null value. In this case, every row in the table with the foreign key must have a corresponding value in the primary key column of the related table.

If a foreign key is defined as nullable, it can contain a null value. This means that a row in the table with the foreign key can exist without a corresponding value in the primary key column of the related table.

Regarding duplication, it depends on the relationship established by the foreign key. If the foreign key is a part of a one-to-one relationship, then it should be unique; otherwise, if the foreign key is a part of a one-to-many relationship, then it's allowed to have duplicate values.

It's worth noting that some database management systems, such as MySQL and SQL Server, allow the use of "NO ACTION" or "SET NULL" on the foreign key constraint, which means that when a referenced row is deleted or updated, the foreign key value will be set to NULL or the deletion/update will not happen respectively.